I have an Angular 2 component that uses the @Input class field decorator as well as getters and setters as follows:
import {Component, Input, Output, EventEmitter,FORM_DIRECTIVES, CORE_DIRECTIVES} from 'angular2/angular2';
@Component({
selector: 'binding-test3',
templateUrl: './components/binding-test/binding-test3.html',
directives: [CORE_DIRECTIVES,FORM_DIRECTIVES]
})
export class BindingTest3 {
@Input() value: string;
@Output() valueChange:EventEmitter = new EventEmitter();
private _value: string;
get value() {
console.log('getting value in BindingTest3: ',this._value);
return this._value;
}
set value(value) {
console.log('setting value in BindingTest3: ',value);
this._value = value;
this.valueChange.next(value);
}
}
The code runs correctly but there are three compiler errors:
app/components/binding-test/binding-test3.ts(15,14): error TS2300: Duplicate identifier 'value'. app/components/binding-test/binding-test3.ts(20,9): error TS2300: Duplicate identifier 'value'. app/components/binding-test/binding-test3.ts(25,9): error TS2300: Duplicate identifier 'value'.
Any ideas on how to solve this?