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
| delete(id: string): void { | |
| this._db | |
| .collection<Jobs>('jobs') | |
| .doc(id) | |
| .delete() | |
| .then(() => { | |
| this.snackBar.open('Job was deleted successfully', 'Ok', { | |
| duration: 2000, | |
| }); | |
| }); |
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
| editJob() { | |
| this._db.collection<any>('jobs') | |
| .doc(this.id) | |
| .update( | |
| { | |
| company: this.jobForm.get('company').value, | |
| description: this.jobForm.get('description').value, | |
| title: this.jobForm.get('title').value | |
| } | |
| ).then(() => { |
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
| ngOnInit() { | |
| this.route.paramMap.subscribe((params: ParamMap) => { | |
| this.id = params.get('id'); | |
| this._db | |
| .collection<Jobs>('jobs') | |
| .doc( | |
| params.get('id') | |
| ).valueChanges() | |
| .subscribe((item) => { | |
| this.jobForm.patchValue(item); |
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
| constructor(public snackBar: MatSnackBar, public afAuth: AngularFireAuth, db: AngularFirestore) { | |
| this.jobs = db | |
| .collection<Jobs>('jobs') | |
| .snapshotChanges() | |
| .pipe(map(actions => { | |
| return actions.map(a => { | |
| const data = a.payload.doc.data(); | |
| const id = a.payload.doc.id; | |
| return { id, ...data }; | |
| }); |
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
| addJob() { | |
| this._db | |
| .collection<Jobs>('jobs') | |
| .add( | |
| { | |
| company: this.jobForm.get('company').value, | |
| description: this.jobForm.get('description').value, | |
| title: this.jobForm.get('title').value | |
| } | |
| ).then(() => { |
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
| jobForm = new FormGroup({ | |
| company: new FormControl('', Validators.required), | |
| description: new FormControl('', Validators.required), | |
| title: new FormControl('', Validators.required), | |
| salary: new FormControl('') | |
| }); |
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 class="job-form" [formGroup]="jobForm"> | |
| <mat-form-field class="full-width"> | |
| <mat-label>Company</mat-label> | |
| <input matInput placeholder="Ex. Google" formControlName="company" required> | |
| <mat-error *ngIf="!jobForm.get('company').valid">Required</mat-error> | |
| </mat-form-field> | |
| <mat-form-field class="full-width"> | |
| <mat-label>Job Title</mat-label> | |
| <input matInput placeholder="Ex. Sr. Software Engineer" formControlName="title" required> | |
| <mat-error *ngIf="!jobForm.get('title').valid">Required</mat-error> |
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
| constructor(db: AngularFirestore) { | |
| this._db = db; | |
| } |
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
| import { Pipe, PipeTransform } from '@angular/core'; | |
| @Pipe({ | |
| name: 'bgColorPipe' | |
| }) | |
| export class BgColorPipePipe implements PipeTransform { | |
| transform(value: any, args?: any): any { | |
| if(value === 'red'){ | |
| console.log('hit'); |
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
| <hello name="{{ name }}"></hello> | |
| <p [ngStyle]="{'background-color': getColor()}"> | |
| Start editing to see some magic happen :) | |
| </p> | |
| <table> | |
| <tr [ngStyle]="{'background-color': getColor()}"> | |
| <th [ngStyle]="{'background-color': getColor()}">Company</th> | |
| <th [ngStyle]="{'background-color': getColor()}">Contact</th> | |
| <th [ngStyle]="{'background-color': getColor()}">Country</th> |
NewerOlder