angularjs – angular-ui-router:在控制器中使用$state的依赖是
发布时间:2020-12-17 17:47:58 所属栏目:安全 来源:网络整理
导读:这可能是一个非常简单的问题,但我在ui-router文档中找不到任何内容.我想调用$state.go()方法来改变控制器中的状态,但是我得到一个“$state not defined”错误. 为了能够使用$state及其方法,我需要在控制器上放置什么依赖? 解决方法 它与任何其他服务相同 –
这可能是一个非常简单的问题,但我在ui-router文档中找不到任何内容.我想调用$state.go()方法来改变控制器中的状态,但是我得到一个“$state not defined”错误.
为了能够使用$state及其方法,我需要在控制器上放置什么依赖? 解决方法
它与任何其他服务相同 – 在带注释的依赖项列表或函数参数中包含它的名称:
//without annotation (inferred,not safe when minifying code) function Controller($scope,$state) {...} //inline annotation module.controller('Controller',['$scope','$state',function($scope,$state) {...}]); //$inject property annotation function Controller($scope,$state) {...} Controller.$inject = ['$scope','$state']; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Bootstrap的Model源码详细注释
- yum 6.8 nginx php-fpm
- 使用scala.util.Try进行for-understanding时的快速失败
- 我应该在Docker镜像中编译我的应用程序
- scala – Spark distinct,后跟join给出IndexOutOfBoundsExc
- 为什么Bash历史上的一些线条变成“*”?
- 单元测试 – Angular 2 TestModuleMetadata没有EntryCompon
- [webservice]com.sun.xml.internal.ws.model.RuntimeModele
- 如何在WebService中获取客户端的IP地址
- 在OSX终端中修改bash提示符前缀[已关闭]