Skip to content

Instantly share code, notes, and snippets.

@Flayed
Created March 29, 2018 16:27
Show Gist options
  • Select an option

  • Save Flayed/e81c8e76e9ede8645d722ea129027597 to your computer and use it in GitHub Desktop.

Select an option

Save Flayed/e81c8e76e9ede8645d722ea129027597 to your computer and use it in GitHub Desktop.
Angular Select
<select [(ngModel)]="myValue">
<option *ngFor="let s of stuff" [value]="s.value">{{s.key}}</option>
</select>
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