Reputation: 1841
I have a service that returns an array of states. It was working (thanks Sajeetharan), but now I'm getting a page error saying that it's not a function.
constructor(
public navCtrl: NavController,
public navParams: NavParams,
private contactService: ContactsProvider,
private stateService: StatesProvider,
private auth: AuthenticationProvider) {
this.contactId = this.navParams.get('contactId');
}
ngOnInit(){
this.contactService.getContactById(this.contactId)
.subscribe(res => {
this.contact = res.json();
this.contactInitials = this.contact.first_name.charAt(0) + this.contact.last_name.charAt(0);
})
this.states = this.stateService.getStates();
}
The specific error is
: Error: Uncaught (in promise): TypeError: this.stateService.getStates is not a function
.
What could cause this?
Upvotes: 0
Views: 249
Reputation: 222552
I guess this quesiton is a continuation of your previous question
in order to access your service method you need to set the access specifier as public
.
public getStates(){
}
Upvotes: 2