编辑angular 4安装的第一个应用程序时出现未捕获错误-angular/cli
我第一次安装angular/cli,只需在编辑angular 4安装的第一个应用程序时出现未捕获错误-angular/cli,angular,Angular,我第一次安装angular/cli,只需在app.component.ts文件中编辑name变量,并更改HTML文件,如下所示 app.component.html: <input type="text" [(ngModel)]="name"> <p>{{ name }}</p> 获取此错误: Uncaught Error: Template parse errors: Can't bind to 'ngModel' since it isn't a kno
app.component.ts
文件中编辑name变量,并更改HTML文件,如下所示
app.component.html:
<input type="text" [(ngModel)]="name">
<p>{{ name }}</p>
获取此错误:
Uncaught Error: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'input'. ("][(ngModel)]="name">
{{ name }}"): ng:///AppModule/AppComponent.html@0:19
at syntaxError (http://localhost:4200/vendor.bundle.js:17734:34)
at TemplateParser.webpackJsonp.../../../compiler/@angular/compiler.es5.js.TemplateParser.parse (http://localhost:4200/vendor.bundle.js:28854:19)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileTemplate (http://localhost:4200/vendor.bundle.js:43006:39)
at http://localhost:4200/vendor.bundle.js:42926:62
at Set.forEach (native)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileComponents (http://localhost:4200/vendor.bundle.js:42926:19)
at http://localhost:4200/vendor.bundle.js:42813:19
at Object.then (http://localhost:4200/vendor.bundle.js:17723:143)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents (http://localhost:4200/vendor.bundle.js:42812:26)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync (http://localhost:4200/vendor.bundle.js:42741:37)
syntaxError @ compiler.es5.js:1690
webpackJsonp.../../../compiler/@angular/compiler.es5.js.TemplateParser.parse @ compiler.es5.js:12810
webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileTemplate @ compiler.es5.js:26962
(anonymous) @ compiler.es5.js:26882
webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileComponents @ compiler.es5.js:26882
(anonymous) @ compiler.es5.js:26769
then @ compiler.es5.js:1679
webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents @ compiler.es5.js:26768
webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync @ compiler.es5.js:26697
webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_._bootstrapModuleWithZone @ core.es5.js:4536
webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule @ core.es5.js:4522
../../../../../src/main.ts @ main.ts:11
__webpack_require__ @ bootstrap e8021dabea79ba711a21:54
0 @ main.ts:11
__webpack_require__ @ bootstrap e8021dabea79ba711a21:54
webpackJsonpCallback @ bootstrap e8021dabea79ba711a21:25
(anonymous) @ main.bundle.js:1
未捕获错误:模板分析错误:
无法绑定到“ngModel”,因为它不是“input”的已知属性。(“][(ngModel)]=“名称”>
{{name}”:ng:///AppModule/AppComponent。html@0:19
在syntaxError(http://localhost:4200/vendor.bundle.js:17734:34)
在templatparser.webpackJsonp…/../../compiler/@angular/compiler.es5.js.templatparser.parse(http://localhost:4200/vendor.bundle.js:28854:19)
在JitCompiler.webpackJsonp…/../compiler/@angular/compiler.es5.js.JitCompiler.\u compileTemplate(http://localhost:4200/vendor.bundle.js:43006:39)
在http://localhost:4200/vendor.bundle.js:42926:62
at Set.forEach(本机)
在JitCompiler.webpackJsonp…/../compiler/@angular/compiler.es5.js.JitCompiler.\u compileComponents(http://localhost:4200/vendor.bundle.js:42926:19)
在http://localhost:4200/vendor.bundle.js:42813:19
那么(http://localhost:4200/vendor.bundle.js:17723:143)
在JitCompiler.webpackJsonp…/../compiler/@angular/compiler.es5.js.JitCompiler.\u compileModuleAndComponents(http://localhost:4200/vendor.bundle.js:42812:26)
在JitCompiler.webpackJsonp…/../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync(http://localhost:4200/vendor.bundle.js:42741:37)
syntaxError@compiler.es5.js:1690
webpackJsonp…/../../compiler/@angular/compiler.es5.js.TemplateParser.parse@compiler.es5.js:12810
webpackJsonp…/../../compiler/@angular/compiler.es5.js.JitCompiler.\u compileTemplate@compiler.es5.js:26962
(匿名)@compiler.es5.js:26882
webpackJsonp…/../../compiler/@angular/compiler.es5.js.JitCompiler.\u compileComponents@compiler.es5.js:26882
(匿名)@compiler.es5.js:26769
然后@compiler.es5.js:1679
webpackJsonp…/../../compiler/@angular/compiler.es5.js.jitcomiler.\u compileModuleAndComponents@compiler.es5.js:26768
webpackJsonp…/../../compiler/@angular/compiler.es5.js.jitcomiler.compileModuleAsync@compiler.es5.js:26697
webpackJsonp…/../../core/@angular/core.es5.js.PlatformRef.\u bootstrapModuleWithZone@core.es5.js:4536
webpackJsonp…/../../core/@angular/core.es5.js.PlatformRef\uuu.bootstrapModule@core.es5.js:4522
../../../src/main.ts@main.ts:11
__webpack_require__@bootstrap e8021dabea79ba711a21:54
0@main.ts:11
__webpack_require__@bootstrap e8021dabea79ba711a21:54
webpackJsonpCallback@bootstrap e8021dabea79ba711a21:25
(匿名)@main.bundle.js:1
已安装最新版本的node、npm和angular/cli,请将其添加到appmodule:
导入:[FormsModule]
您需要它才能使用ngModel请检查您是否已在app.module.ts文件中导入FormsModule 如果没有,请添加以下代码
import { FormsModule} from '@angular/forms';
imports: [
FormsModule ],
import { FormsModule} from '@angular/forms';
imports: [
FormsModule ],