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
| interface Movie { | |
| id: number; | |
| title: string; | |
| } | |
| @Component({ | |
| selector: 'app-some-component-with-form', | |
| template: `...` // our form is here | |
| }) | |
| export class SomeComponentWithForm { |
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
| interface Movie { | |
| id: number; | |
| title: string; | |
| } | |
| interface User { | |
| firstName: string; | |
| lastName: string; | |
| age: number; | |
| favoriteMovies: Array<Movie | number>; |
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
| @Component({ | |
| selector: 'app-some-component-with-form', | |
| template: `...` // our form is here | |
| }) | |
| export class SomeComponentWithForm { | |
| public form: FormGroup; | |
| public movies: Array<Movie> | |
| constructor(private formBuilder: FormBuilder){ |
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
| @Component({ | |
| selector: 'some-component', | |
| template: ` | |
| <div> | |
| <dropdown-component [options]="weightUnits"></dropdown-component> | |
| <-- This will render a dropdown based in the options --> | |
| <input type="text" placeholder="Price"> | |
| <dropdown-component [options]="weightUnits"></dropdown-component> | |
| <-- We need to make this one's labels to be preceded with a slash --> | |
| </div> |
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
| @Component({ | |
| selector: 'some-component', | |
| template: ` | |
| <div> | |
| <dropdown-component [options]="weightUnits"></dropdown-component> | |
| <input type="text" placeholder="Price"> | |
| <dropdown-component [options]="slashedWeightUnits"></dropdown-component> | |
| <-- Now this one's labels will be preceded with a slash --> | |
| </div> | |
| ` |
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
| @Component({ | |
| selector: 'some-component', | |
| template: ` | |
| <div> | |
| <dropdown-component [options]="weightUnits"></dropdown-component> | |
| <input type="text" placeholder="Price"> | |
| <dropdown-component [options]="slashedWeightUnits"></dropdown-component> | |
| <-- Now this one's labels will be preceded with a slash --> | |
| </div> | |
| ` |
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
| @Pipe({ | |
| name: 'slashed' | |
| }) | |
| export class Slashed implements PipeTransform { | |
| transform(value){ | |
| return value.map(item => { | |
| return { | |
| label: '/' + item.label, | |
| value: item.value | |
| }; |
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
| @Pipe({ | |
| name: 'map' | |
| }) | |
| export class Mapping implements PipeTransform { | |
| /* | |
| this will be a universal pipe for array mappings. You may add more | |
| type checkings and runtime checkings to make sure it works correctly everywhere | |
| */ | |
| transform(value, mappingFunction: Function){ | |
| return mappingFunction(value) |
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
| interface User { | |
| fullname: string; | |
| age: number; | |
| createdDate: string | Date; | |
| } |
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
| interface Order { | |
| status: 'pending' | 'approved' | 'rejected'; | |
| } |