This file contains hidden or 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
| <ng-container *ngIf="form$ | async as form; else loading"> | |
| <form [formGroup]="form"> | |
| <div class="form-group"> | |
| <label for="">Title</label> | |
| <input class="form-control" type="text" formControlName="title" /> | |
| </div> | |
| <div class="form-group"> | |
| <label for="exampleFormControlSelect2">Body</label> | |
| <textarea | |
| class="form-control" |
This file contains hidden or 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 AppComponent{ | |
| form: Observable<FormArray>; | |
| constructor(private fb: FormBuilder) {} | |
| ngOnInit() { | |
| this.formArray$ = this.posts$.pipe( | |
| map(posts => this.fb.array(posts.map(post => this.fb.group(post)))) |
This file contains hidden or 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
| <ng-container *ngIf="formArray$ | async as formArray; else loading"> | |
| <form> | |
| <ng-container *ngFor="let formGroup of formArray.controls"> | |
| <div [formGroup]="formGroup"> | |
| <div class="form-group"> | |
| <label for="">Title</label> | |
| <input class="form-control" type="text" formControlName="title" /> | |
| </div> | |
| <div class="form-group"> | |
| <label for="exampleFormControlSelect2">Body</label> |
This file contains hidden or 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
| this.title$ = this.form$.pipe( | |
| switchMap(form => form.controls.title.valueChanges.pipe(shareReplay(1))) | |
| ); | |
| this.body$ = this.form$.pipe( | |
| switchMap(form => form.controls.body.valueChanges.pipe(shareReplay(1)))) | |
| ; |
This file contains hidden or 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
| ... | |
| form$: Observable<FormGroup>; | |
| constructor(private fb: FormBuilder) {} | |
| ngOnInit() { | |
| post$ = this.store.select(postQuery.selectCurrentPost); | |
| form$ = this.post$.pipe(map(post => this.fb.group(post))); | |
| } |
This file contains hidden or 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
| form$: Observable<FormGroup>; |
This file contains hidden or 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 Queue<T> { | |
| constructor(private length: number, private data: T[] = []) {} | |
| } |
This file contains hidden or 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 Queue<T> { | |
| constructor(private length: number, private data: T[] = []) {} | |
| add(record) { | |
| const length = this.data.unshift(record); | |
| } | |
| } |
This file contains hidden or 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 Queue<T> { | |
| constructor(private length: number, private data: T[] = []) {} | |
| add(record) { | |
| const length = this.data.unshift(record); | |
| if (length > this.length) { | |
| this.remove(); | |
| } | |
| } |
This file contains hidden or 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 Queue<T> { | |
| constructor(private length: number, private data: T[] = []) {} | |
| add(record) { | |
| const length = this.data.unshift(record); | |
| if (length > this.length) { | |
| this.remove(); | |
| } | |
| } |