Skip to content

Instantly share code, notes, and snippets.

@Armenvardanyan95
Created July 2, 2017 12:05
Show Gist options
  • Save Armenvardanyan95/b495d28160d986eae622f29fabff4390 to your computer and use it in GitHub Desktop.
Save Armenvardanyan95/b495d28160d986eae622f29fabff4390 to your computer and use it in GitHub Desktop.
@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