Angular-Meteor 在构造函数之外使用 $state

Angular-Meteor using $state outside of the constructor

我是 Angular-Meteor 的新手。我注意到我可以在构造函数方法中使用 $state(作为参数传递),但它在构造函数之外的方法中不会真正起作用。在构造方法之外使用它(如果)的正确方法是什么?

我的技术是将它设置为等于 this 上的类似名称的 属性。

举个例子:

this.$state = $state;

然后要在其他方法中访问它,您可以在整个 class.

中通过 this.$state