【发布时间】:2017-04-10 19:11:12
【问题描述】:
当我运行这样的代码时,我的控制器停止工作,并且它发生在通过解析传递的各种数据,从 api 或任何其他方式.. 我无法将任何东西传递给我的控制器
> $urlRouterProvider.otherwise('/movies')
> $stateProvider
> .state('movies', {
> url: '/movies',
> templateUrl: 'templates/movies.html',
> controller: 'indexCtrl',
> resolve: {
> resolveParam: function(){
> return 'sdsadasdasd'
> }
> }
> })
>
> }]);
>
>
> app.controller('indexCtrl', ['$scope', 'resolveParam', function($scope, resolveParam) {
> $scope.click = function() {
> alert();
>
>
>
> }
> }]);
只要我这样运行它就可以正常工作
app.controller('indexCtrl', ['$scope', function($scope) {
$scope.click = function() {
alert();
}
}]);
即使我的状态仍然和上面一样..
【问题讨论】:
-
你的 resolve 需要返回一个 promise。
-
那么它应该像这样pokit.org/get/img/9968e3ce68f6d8e13d7b4c35c66a5b9b.jpg 工作,但它没有
-
堆栈跟踪是否有错误?
-
只是前端应用,在 VS Code 中工作
标签: javascript jquery angularjs angular-ui-router resolve