Reputation: 542
I have created getter-setter as following using typescript in Angular5:-
private _locations: Array<string> = [];
constructor() { }
/**
* Getter locations
* @return {Array<string>}
*/
public get locations(): Array<string> {
return this._locations;
}
/**
* Setter locations
* @param {Array<string>} value
*/
public set locations(value: Array<string>) {
this._locations = value;
}
When I try to access method locations
this.signUpService.locations();
I am getting an error : [ts] Cannot invoke an expression whose type lacks a call signature. Type 'string[]' has no compatible call signatures.
Upvotes: 3
Views: 644
Reputation: 275927
this.signUpService.locations();
getters are not invoked. They are simply got
const value = this.signUpService.locations;
This is just TypeScript saving you.
Upvotes: 9