Created
March 29, 2018 16:27
-
-
Save Flayed/e81c8e76e9ede8645d722ea129027597 to your computer and use it in GitHub Desktop.
Angular Select
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
| <select [(ngModel)]="myValue"> | |
| <option *ngFor="let s of stuff" [value]="s.value">{{s.key}}</option> | |
| </select> |
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 { Component } from '@angular/core'; | |
| export interface MyStuff { | |
| key: string; | |
| value: number; | |
| } | |
| @Component({ | |
| selector: 'app-my', | |
| templateUrl: './my.component.html' | |
| }) | |
| export class MyComponent { | |
| public stuff = [ | |
| new <MyStuff>({key: 'Unknown', value: 0}), | |
| new <MyStuff>({key: 'Primary', value: 1}), | |
| new <MyStuff>({key: 'Secondary', value: 2}) | |
| ]; | |
| public myValue: number; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment