简体   繁体   中英

How to solve out the $event issue in angular application when I'm using and Angular Material and some code customizing it

I found an issue in Angular 6 version with that using Angular Material. Anybody can help me to fixed this error of $event.

 ERROR Error: Cannot assign value "$event" to template variable "nameValue". Template variables are read-only. at _AstToIrVisitor.push../node_modules/@angular/compiler/fesm5/compiler.js._AstToIrVisitor.visitPropertyWrite (compiler.js:8719) at PropertyWrite.push../node_modules/@angular/compiler/fesm5/compiler.js.PropertyWrite.visit (compiler.js:7589) at convertActionBinding (compiler.js:8320) at prepareEventListenerParameters (compiler.js:17473) at Object.params (compiler.js:18598) at compiler.js:18369 at Array.map (<anonymous>) at compiler.js:18369 at compiler.js:17630 at Array.map (<anonymous>)

I didn't use any template variable. I put it directly in the Html.

 Unhandled Promise rejection: Cannot assign value "$event" to template variable "nameValue". Template variables are read-only. ; Zone: <root>; Task: Promise.then; Value: Error: Cannot assign value "$event" to template variable "nameValue". Template variables are read-only. at _AstToIrVisitor.push../node_modules/@angular/compiler/fesm5/compiler.js._AstToIrVisitor.visitPropertyWrite (compiler.js:8719) at PropertyWrite.push../node_modules/@angular/compiler/fesm5/compiler.js.PropertyWrite.visit (compiler.js:7589) at convertActionBinding (compiler.js:8320) at prepareEventListenerParameters (compiler.js:17473) at Object.params (compiler.js:18598) at compiler.js:18369 at Array.map (<anonymous>) at compiler.js:18369 at compiler.js:17630 at Array.map (<anonymous>) Error: Cannot assign value "$event" to template variable "nameValue". Template variables are read-only. at _AstToIrVisitor.push../node_modules/@angular/compiler/fesm5/compiler.js._AstToIrVisitor.visitPropertyWrite (http://localhost:4200/vendor.js:39190:27) at PropertyWrite.push../node_modules/@angular/compiler/fesm5/compiler.js.PropertyWrite.visit (http://localhost:4200/vendor.js:38060:24) at convertActionBinding (http://localhost:4200/vendor.js:38791:45) at prepareEventListenerParameters (http://localhost:4200/vendor.js:47944:23) at Object.params (http://localhost:4200/vendor.js:49069:20) at http://localhost:4200/vendor.js:48840:90 at Array.map (<anonymous>) at http://localhost:4200/vendor.js:48840:56 at http://localhost:4200/vendor.js:48101:83 at Array.map (<anonymous>)

Any solution for this

I had the same problem with Angular 9. I figured out that I had declared a variable like "let nameValue of values" and after I did [(item)]=nameValue on the Template. The problem was I had assigned item to nameValue with double-binding. Removing the () solved my problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM