如何將cookie添加到我的控制器是否正確?
當我使用$ cookie時發生錯誤,否則一切正常。
angular.module('app', ['ngCookies']);
app.controller('loginCtrl', function ($scope, $http, $state, Authorization, $cookies) {
$cookies.put('expires', 'example');
});
錯誤
angular.js:13920 Error: [$injector:unpr] http://errors.angularjs.org/1.5.8/ $injector/unpr?p0=%24cookiesProvider%20%3C-%20%24cookies%20%3C-%20loginCtrl at Error (native) at http://localhost:64757/Scripts/angular.min.js:6:412 at http://localhost:64757/Scripts/angular.min.js:43:174 at Object.d [as get] (http://localhost:64757/Scripts/angular.min.js:40:432) at http://localhost:64757/Scripts/angular.min.js:43:236 at d (http://localhost:64757/Scripts/angular.min.js:40:432) at e (http://localhost:64757/Scripts/angular.min.js:41:158) at Object.instantiate (http://localhost:64757/Scripts/angular.min.js:42:24) at http://localhost:64757/Scripts/angular.min.js:90:32 at q (http://localhost:64757/Scripts/AngularUI/ui-router.min.js:7:14338)
你會得到什麼錯誤? – sp00m
@ sp00m我加入了我的文章:) –