Angularjs $位置在控制器内未定义

时间:2016-01-18 21:27:29

标签: angularjs angular-ui-router

我已向控制器注入了$ location服务。但$ location服务未在方法内定义。请帮忙。

app.controller('MainCtrl',['$scope','$location','$mdDialog','MainViewService','$http',
     function($scope, $location,$mdDialog,MainViewService,$http) {
        $scope.pushView = function(){
                    //$location.path
                    //$locaiton undefined <-- Problem
            };
    }]);

1 个答案:

答案 0 :(得分:1)

你错过了结束括号!

app.controller('MainCtrl',['$scope','$location','$mdDialog','MainViewService','$http',
    function($scope, $location,$mdDialog,MainViewService,$http) {
    $scope.pushView = function(){
                //$location.path
                //$locaiton undefined <-- Problem
        };
}
] // <-- missing closing bracket
);