I am trying to explore Angular2 with this simple task. I have a select element,
<select [(ngModel)]="selected" (ngModelChange)="selectedChanged()" id="boolopt">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
I want to print this selected value onto my console, which I am trying to access in a Component.
@Component({
selector: 'step',
moduleId: module.id,
templateUrl: 'Opt.component.html',
})
export class Opt{
selected:string = '';
selectedChanged() {
console.log(this.selected);
}
}
After going through similar links on how to get the selected value from dropdown list, I could gather so much info. But now I am getting an error
Cannot read property 'selectedChanged' of undefined
Any help is appreciated. Thanks in advance :)