angular-meteor

Angular-Meteor using $state outside of the constructor


I'm new to Angular-Meteor. I noticed I could use $state in the constructor method (passed as a param), but it won't really work in methods outside of the constructor. What's the correct way of using it (if) outside the constructor method?


Solution

  • My technique is to set it equal to a similarly named property on this.

    As an example:

    this.$state = $state;
    

    Then to access it in the other methods, you can via this.$state throughout your class.