I am trying to use two-way binding in Angular 4. He...">

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
angular


source to share


No one has answered this question yet

Check out similar questions:

185
Can't bind to 'formControl' as it is not a known "input" property - angular2 stuff. Autocomplete
7
Double-sided binding on angular 6 reactive form
4
Can't create property 'validator' on string
1
Cannot read property "from" undefined
0
The pipe does not work in the corner2
0
Angular 2 Data Binding (Unable to read property "proposta_usuario" undefined)
0
Angular 2 user input form: cannot read property "subscribe" undefined
0
Angular generic: "Unable to read property" _updateTreeValidity "undefined"
0
ERROR TypeError: Unable to read property 'seatavailable' from undefined
-2
Cannot read undefined property in Angular



All Articles
Loading...
X
Show
Funny
Dev
Pics