Created
July 2, 2017 12:05
-
-
Save Armenvardanyan95/b495d28160d986eae622f29fabff4390 to your computer and use it in GitHub Desktop.
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> | |
| ` | |
| }) | |
| export class SomeComponent { | |
| public weightUnits = [{value: 1, label: 'kg'}, {value: 2, label: 'oz'}]; | |
| public get slashedWeightUnits() { | |
| return this.weightUnits.map(weightUnit => { | |
| return { | |
| label: '/' + weightUnit.label, | |
| value: weightUnit.value | |
| }; | |
| }) | |
| } | |
| // so now we map existing weight units to a new array | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment