【发布时间】:2018-08-19 23:58:33
【问题描述】:
如何从选择组件中获取选定的值?
select.component.ts:
export class PfSelectComponent implements OnInit {
constructor() { }
ngOnInit() {
}
@Input() options : Array<Object>;
}
select.component.html
<select [(ngModel)]="selectedValue" id="exampleFormControlSelect1" class="form-control">
<option *ngFor="let option of options" [ngValue]="option.value">{{option.name}}</option>
</select>
select value: {{selectedValue}}
{{selectValue}} 不显示组件中选择的值。
【问题讨论】:
-
您是否将
selectedValue添加为PfSelectComponent类的成员? -
@Input() selectedValue;喜欢这个?没用
标签: angular typescript components