只是尝试学习Angular并遇到错误。
@Component({
template:`
<input [(ngModel)]="email" (keyup.enter)="onAnotherBinding()"/>
`
})
export class CoursesComponent implements OnInit {
email = "abc@email.com"
onAnotherBinding(){
console.log("the data entered by the user is --> " + this.email);
}
}
运行此程序时出现以下错误:
compiler.js:15826 Uncaught Error: Cannot assign to a reference or variable!
at _AstToIrVisitor.push../node_modules/@angular/compiler/fesm5/compiler.js._AstToIrVisitor.visitPropertyWrite (compiler.js:15826)
at PropertyWrite.push../node_modules/@angular/compiler/fesm5/compiler.js.PropertyWrite.visit (compiler.js:3311)
at convertActionBinding (compiler.js:15513)
at compiler.js:17074
at Array.forEach (<anonymous>)
at ViewBuilder.push../node_modules/@angular/compiler/fesm5/compiler.js.ViewBuilder._createElementHandleEventFn (compiler.js:17070)
at nodes.(:4200/anonymous function) (http://localhost:4200/vendor.js:22812:23)
at compiler.js:17032
at Array.map (<anonymous>)
at ViewBuilder.push../node_modules/@angular/compiler/fesm5/compiler.js.ViewBuilder._createNodeExpressions (compiler.js:17031) push../node_modules/@angular/compiler/fesm5/compiler.js._AstToIrVisitor.visitPropertyWrite @ compiler.js:15826 push../node_modules/@angular/compiler/fesm5/compiler.js.PropertyWrite.visit @ compiler.js:3311 convertActionBinding @ compiler.js:15513 (anonymous) @ compiler.js:17074 push../node_modules/@angular/compiler/fesm5/compiler.js.ViewBuilder._createElementHandleEventFn @ compiler.js:17070 nodes.(anonymous function) @ compiler.js:16668 (anonymous) @ compiler.js:17032 push../node_modules/@angular/compiler/fesm5/compiler.js.ViewBuilder._createNodeExpressions @ compiler.js:17031 push../node_modules/@angular/compiler/fesm5/compiler.js.ViewBuilder.build @ compiler.js:16503 push../node_modules/@angular/compiler/fesm5/compiler.js.ViewCompiler.compileComponent @ compiler.js:16425 push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate @ compiler.js:23988 (anonymous) @ compiler.js:23930 push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents @ compiler.js:23930 (anonymous) @ compiler.js:23840 then @ compiler.js:1007 push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents @ compiler.js:23839 push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.compileModuleAsync @ compiler.js:23799 push../node_modules/@angular/platform-browser-dynamic/fesm5/platform-browser-dynamic.js.CompilerImpl.compileModuleAsync @ platform-browser-dynamic.js:143 push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule @ core.js:4352 ./src/main.ts @ main.ts:11
__webpack_require__ @ bootstrap:76 0 @ main.ts:12
__webpack_require__ @ bootstrap:76 checkDeferredModules @ bootstrap:43 webpackJsonpCallback @ bootstrap:30 (anonymous) @ main.js:1