加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 无法注入$location服务

发布时间:2020-12-17 17:31:31 所属栏目:安全 来源:网络整理
导读:这段代码给了我错误:[$injector:unpr]未知提供者:$scope,$locationProvider - $scope,$location. var app = angular.module('myApp.controllers',[]);app.controller('Signup',['$scope,$location',function($scope,$location) { $scope.checkEmailValid
这段代码给了我错误:[$injector:unpr]未知提供者:$scope,$locationProvider< - $scope,$location.

var app = angular.module('myApp.controllers',[]);

app.controller('Signup',['$scope,$location',function($scope,$location) {
    $scope.checkEmailValid = function(){
        //TODO make a decision about whether to go somewhere,if true do this:
        $location.path('/view2');
    };
}]);

我错过了有关如何注入位置服务的内容吗?
我没有配置$locationProvider,但这样做似乎没有帮助.

解决方法

你忘记了$scope和$location附近的报价:

var app = angular.module('myApp.controllers',['$scope','$location',if true do this:
        $location.path('/view2');
    };
}]);

这应该是诀窍!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读