Angular version 2,...,9 provides several ways to add classes conditionally:
type one
[class.my-class]="step === 'step1'"
type two
[ngClass]="{'my-class': step === 'step1'}"
and multiple option:
| import { Injectable } from '@angular/core'; | |
| @Injectable({ | |
| providedIn: 'root', | |
| }) | |
| export class LocalstorageService { | |
| constructor() {} | |
| set(key: string, value: any) { | |
| localStorage.setItem(key, JSON.stringify(value)); |
Angular version 2,...,9 provides several ways to add classes conditionally:
type one
[class.my-class]="step === 'step1'"
type two
[ngClass]="{'my-class': step === 'step1'}"
and multiple option:
| ngOnChanges(changes: SimpleChanges): void { | |
| for (const property in changes) { | |
| if (changes.hasOwnProperty(property)) { | |
| switch (property) { | |
| case 'someInputName': { | |
| // do something | |
| } | |
| } | |
| } | |
| } |
| #!/bin/bash | |
| # description script to locally check if your password has been breached using haveibeenpwned.com hashes | |
| # usage bash mkscript.sh | |
| # dependencies bash, 7z, grep, wget | |
| #============================================================================== | |
| # checking prerequirements | |
| sha1HashFile="pwned-passwords-sha1-ordered-by-hash-v5" | |
| if ! test -f "$sha1HashFile.txt"; then | |
| read -p "Password hashes not found. Download the file now? (y/n)" -n 1 -r |
| FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 | |
| # adding debian contrib package sources (https://www.debian.org/doc/debian-policy/ch-archive.html) | |
| RUN apt-get update | |
| RUN apt-get install -y --no-install-recommends software-properties-common | |
| RUN apt-add-repository contrib | |
| RUN apt-get update | |
| # installing mscorefonts | |
| RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections |
| # inside your .bashrc or .zshrc (on the server side) add: | |
| # start tmux if we ssh into the box | |
| if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then | |
| tmux attach-session -t $USER || tmux new-session -s $USER | |
| fi | |
| # this will attach to an ongoing tmux session or start a new one | |
| # the session name will be the name of the user ($USER) |
| import { tap, debounceTime, map, filter } from 'rxjs/operators'; | |
| this.$someSubject | |
| .pipe( | |
| tap(console.log), | |
| debounceTime(this.inputDebounceTime), | |
| map(value => parseFloat(value)), | |
| filter(value => !isNaN(value)), | |
| ).subscribe(result => { | |
| // ... |
| import 'rxjs/add/operator/map'; | |
| import 'rxjs/add/operator/debounceTime'; | |
| import 'rxjs/add/operator/distinctUntilChanged'; | |
| //import … | |
| this.$someSubject | |
| .do(console.log) | |
| .debounceTime(800) | |
| .map(value => parseFloat(value)) | |
| .filter(value => !isNaN(value)) |