Cannot assign only the "dataChange" property of a read only object # # ValidationComponent>
I am trying to use two-way binding in Angular 4. Here is my component code:
@Component({
selector: 'form-validation',
templateUrl: './form.validation.template.html',
encapsulation: ViewEncapsulation.None
})
export class ValidationComponent {
@Input() data;
@Output dataChange = new EventEmitter();
//...
}
But when I try to use it on something like this:
<form-validation [(data)]="data"></form-validation>
I am getting this error on Chrome console:
Cannot assign to read only property 'dataChange' of object '#<ValidationComponent>'
A property data
is an array of a specific type, but even if I report that type or initialize the property, an error occurs.
+3
source to share
No one has answered this question yet
Check out similar questions: