11

I am trying to use a 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 it:

<form-validation [(data)]="data"></form-validation>

I get this error on Chrome's console:

Cannot assign to read only property 'dataChange' of object '#<ValidationComponent>'

The data property is an array of a specific type, but even if I inform this type or inicialize the property the error happens.

georgeawg
  • 46,994
  • 13
  • 63
  • 85
fred00
  • 521
  • 2
  • 6
  • 22

1 Answers1

0

Just to make it clear, the answer below is by harry ninh in a comment above

It should be @Output() instead of @Output

M Akin
  • 342
  • 2
  • 13