Angular2错误:没有指令,“exportAs”设置为“ngForm”

前端之家收集整理的这篇文章主要介绍了Angular2错误:没有指令,“exportAs”设置为“ngForm”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在RC4,我收到错误没有指令,“exportAs”设置为“ngForm”,因为我的模板:
<div class="form-group">
        <label for="actionType">Action Type</label>
        <select
            ngControl="actionType" 
      ===>  #actionType="ngForm" 
            id="actionType" 
            class="form-control" 
            required>
            <option value=""></option>
            <option *ngFor="let actionType of actionTypes" value="{{ actionType.label }}">
                {{ actionType.label }}
            </option>
        </select> 
    </div>

boot.ts:

import {disableDeprecatedForms,provideForms} from '@angular/forms'; 

 import {bootstrap} from '@angular/platform-browser-dynamic';
 import {HTTP_PROVIDERS,Http} from '@angular/http';
 import {provideRouter} from '@angular/router';

import {APP_ROUTER_PROVIDER} from './routes';

import {AppComponent} from './app.component';

bootstrap(AppComponent,[ disableDeprecatedForms(),provideForms(),APP_ROUTER_PROVIDER,HTTP_PROVIDERS]);

///所以这里是我的DropdownList:

<fieldset ngControlGroup="linkedProcess" >
                     <div ngControlGroup="Process" >
                         <label>Linked Process</label>
                          <div class="form-group">       
        <select 
            ngModel
            name="label" 
            #label="ngModel" 
            id="label" 
            class="form-control" required
            (change)="reloadProcesse(list.value)" 
            #list>
            <option value=""></option>
            <!--<option value=`{{ActionFormComponent.getFromString('GET'')}}`></option>-->                 
            <option *ngFor="let processus of linkedProcess?.processList?.list; let i = index" 
            value="{{ processus[i].Process.label}}">
                {{processus.Process.label}}
            </option>
        </select> 
        </div>
     </div>

//我的组件ts:

我以这样的旧形式表示:

categoryControlGroups:ControlGroup[] = [];
     categories:ControlArray = new ControlArray(this.categoryControlGroups);

现在我在做这个:

categoryControlGroups:FormGroup[] = [];
     categories:FormArray = new FormArray(this.categoryControlGroups);

你认为这是prob的原因?

我面对同样的问题。我错过了app.module.component.ts类中的表单模块导入标记
import { FormsModule } from '@angular/forms';

@NgModule({
    imports: [BrowserModule,FormsModule
    ],

猜你在找的Angularjs相关文章