使用RC5表示已弃用的错误

时间:2016-08-11 22:30:46

标签: angular

错误:"您似乎正在使用旧表单模块。这将在下一个RC中选择加入,并最终将被删除以支持新的表单模块。"

为什么我收到此错误?新表格界面的文档在哪里?

当我使用FormsModule时,为什么需要以下内容?

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


         <form *ngIf="postingMessage">
        <h3>New Message</h3>
        <label>Subject:</label><br>
        <input [(ngModel)]="postingMessage.subject" 
        class="form-control"
        type="text" 
        id="subject"
        required
        autofocus
        size="80"
        [ngClass]="{invalid: subject.touched && !subject.valid}"
        name="subject" #subject="ngModel"><br>
        <div [hidden]="subject.valid || subject.pristine" 
         class="alert alert-danger">
        Subject is required
        </div>
        <label>Message:</label><br>
        <textarea [(ngModel)]="postingMessage.body" rows="10" cols="80" 
        name="name" ></textarea>

    </form>

1 个答案:

答案 0 :(得分:1)

注意:文档似乎缺失或尚未完成。

RC5 中,我们推出了新的 NgModule

<强> You can learn form with NgModule implementation here

<强> breaking changes in RC5

<强>之前:

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

bootstrap(App, [
  disableDeprecatedForms(),
  provideForms()
]);

<强>后:

import {DeprecatedFormsModule} from @angular/common;

@NgModule({
  declarations: [MyComponent],
  imports: [BrowserModule, DeprecatedFormsModule],
  bootstrap:  [MyComponent],
})
export class MyAppModule{}