简体   繁体   English

功能正在运行,但现在说它不是功能

[英]Function was working, but now says it is not a function

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. 它正在工作(感谢Sajeetharan),但是现在我收到一个页面错误,说它不是一个函数。

  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 :错误:未捕获(承诺):TypeError:this.stateService.getStates不是函数

.

What could cause this? 是什么原因造成的?

I guess this quesiton is a continuation of your previous question 我想这个问题是您上一个question的延续

in order to access your service method you need to set the access specifier as public . 为了访问您的服务方法,您需要将访问说明符设置为public

public getStates(){

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM