13

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
  • 48,608
  • 13
  • 72
  • 95
fred00
  • 571
  • 2
  • 8
  • 23

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
  • 446
  • 6
  • 18