Usm*_*hir 14 angular angular-forms
我试图select在Angular 5中实现,但我不断得到这个
我已经尝试了很多StackOverflow问题,唯一的区别是 - 我的组件位于应用程序内的另一个模块中,最后注入主模块.我也尝试过注入FormsModule内部模块.我尝试过导入ReactiveFormsModule 但没有工作.
我添加了FormsModule这样的导入
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
@NgModule({
declarations: [
...CombineComponents
],
imports: [
BrowserModule,
FormsModule,
AppRoutingModule,
HttpClientModule
]
});
Run Code Online (Sandbox Code Playgroud)
这是我的组件标记
<label for="ctn" class="d-inline-block pl-1 semi-bold">Current active number</label>
<select
#selectElem
class="custom-select"
id="ctn"
(change)="onCTNChange(selectElem.value)"
formControlName="state"
>
<option value="" disabled>Choose a state</option>
<option *ngFor="let ctn of availableCTN" [ngValue]="ctn.value">
{{ctn.text}}
</option>
</select>
Run Code Online (Sandbox Code Playgroud)
FRE*_*CIA 21
用途value:
[value]="ctn.value"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14613 次 |
| 最近记录: |