加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 没有将“exportAs”设置为“ngForm”的指令

发布时间:2020-12-17 07:54:53 所属栏目:安全 来源:网络整理
导读:拥有此项目依赖项: "dependencies": { "@angular/common": "2.0.0-rc.6","@angular/compiler": "2.0.0-rc.6","@angular/core": "2.0.0-rc.6","@angular/forms": "2.0.0-rc.6","@angular/http": "2.0.0-rc.6","@angular/platform-browser": "2.0.0-rc.6","@a
拥有此项目依赖项:
"dependencies": {
    "@angular/common": "2.0.0-rc.6","@angular/compiler": "2.0.0-rc.6","@angular/core": "2.0.0-rc.6","@angular/forms": "2.0.0-rc.6","@angular/http": "2.0.0-rc.6","@angular/platform-browser": "2.0.0-rc.6","@angular/platform-browser-dynamic": "2.0.0-rc.6","@angular/router": "3.0.0-rc.2","ng2-bootstrap": "^1.1.1","reflect-metadata": "^0.1.8","core-js": "^2.4.0","es6-module-loader": "^0.17.8","rxjs": "5.0.0-beta.11","systemjs": "0.19.27","zone.js": "0.6.17","jquery": "3.0.0",}

这个登录模板:

<form #loginForm="ngForm" (ng-submit)="authenticate(loginForm.value)">
</form>

而这个登录组件:

import { Component } from '@angular/core';
import {Http,Headers}  from '@angular/http';
@Component({
    moduleId: module.id,selector: 'login-cmp',templateUrl: 'login.component.html'
})
export class LoginComponent {
  constructor($http: Http) {
    this.$http = $http;
  }
  authenticate(data) {
   ... 
  }
}

我有这个错误:

zone.js?1474211973422:484 Unhandled Promise rejection: Template parse errors:    
There is no directive with "exportAs" set to "ngForm" ("
            <form [ERROR ->]#loginForm="ngForm" 
(ngsubmit)="authenticate(loginForm.value)">
import { FormsModule }   from '@angular/forms';

@NgModule({
  imports: [
             BrowserModule,FormsModule      //<----------make sure you have added this.
           ],....
})

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读