This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declaring signals Start | |
let quantity = signal<number>(1) | |
let numberList = signal([1,2,3,4]) | |
let vehicle = signal<Vehicle>({'id':'1234',VIN:'MH12VZ0123'}) | |
let vehicleArr = signal<Vehicle[]>([]) | |
// Declaring Computed Signals | |
let price = computed(()=>{ | |
return quantity()*1000 | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { takeUntilDestroyed,toSignal} from '@angular/core/rxjs-interop'; | |
import { CommonModule } from '@angular/common'; | |
@Component({ | |
selector: 'app-unsub-observable-two', | |
standalone: true, | |
imports: [CommonModule], | |
template:`<p *ngIf="timerSignal()">unsub-observable-two works!</p>` | |
}) | |
export class UnsubObservableTwoComponent { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { takeUntilDestroyed} from '@angular/core/rxjs-interop'; | |
import { CommonModule } from '@angular/common'; | |
@Component({ | |
selector: 'app-unsub-observable-two', | |
standalone: true, | |
imports: [CommonModule], | |
templateUrl: './unsub-observable-two.component.html', | |
}) | |
export class UnsubObservableTwoComponent{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub = new Subject<boolean>(); | |
ngOnInit(): void { | |
this.subscribeSave(); | |
} | |
subscribeSave(){ | |
this.sub.asObservable().pipe( | |
exhaustMap((x)=>this.dataService.saveData(this.form.getRawValue())) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
path: 'bad/:id', | |
component: BadComponetDesignComponent, | |
canDeactivate:[candeactivateGuard] | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class BadComponetDesignComponent implements Candeactivate { | |
form!: UntypedFormGroup; | |
candeactivate():boolean{ | |
return this.form.touched; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Candeactivate { | |
candeactivate:()=>boolean | |
} | |
export const candeactivateGuard: CanDeactivateFn<Candeactivate> = ( | |
component: any, | |
currentRoute, | |
currentState, | |
nextState | |
) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
concat(...arr).subscribe((response: any) => { | |
//handle response | |
}, noop, // handle error | |
() => { | |
// refresh content | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arr = [] | |
validations.forEach(a => { | |
let model = { | |
orderId: this.orderId, | |
SubOrderId: this.SubOrderId | |
}; | |
arr.push(this.validationService.sendValidations(model)); // sendValidations returns an observable | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor(public dialog: MatDialog){} | |
async openDialog(data: any) { | |
await import( | |
/* webpackPrefetch: true */ | |
'../../module-folder/module-name.module' | |
); | |
let dialogRef = this.dialog.open(YourComponent, { | |
panelClass: 'my-class', | |
data: data, |
NewerOlder