Angular - $cookies is undefined
Angular - $cookies is undefined
我试图在我的控制器中使用Angular cookie,但由于某些原因,它总是未定义:
MyApp.controller('ValidationController', ["$cookies", function($cookies) {
debugger; //checking $cookies here return an object
$cookies.put("test","test"); //trying to add value to the cookie here return TypeError: undefined is not a function
alert(JSON.stringify($cookies));
}]);
var MyApp = angular.module("MyApp", [
"ui.router",
"ui.bootstrap",
"oc.lazyLoad",
"ngSanitize",
"ngCookies"
]);
这是全栈错误:
TypeError: undefined is not a function
at new <anonymous> (CookiesController.js:6)
at Object.e [as invoke] (angular.min.js:37)
at $get.z.instance (angular.min.js:76)
at angular.min.js:59
at s (angular.min.js:7)
at v (angular.min.js:59)
at g (angular.min.js:52)
at angular.min.js:51
at angular.min.js:17
at l.$get.l.$eval (angular.min.js:126)
有什么想法吗?
似乎 你可以用两种方法解决你的问题。 希望这能帮到你,谢谢。$cookies
在angular 1.3.10中没有setter,而angular 1.4.0angular 1.3.10
,请使用$cookieStore
对象而不是$cookies
1.4.0.beta.6
最新版本
相关文章:
- Jquery - table.row(tr) is undefined
- $routeParams is undefined
- Angular js $scope is Undefined
- Angular - $cookies is undefined
- TypeError: e is undefined - javascript
- “google.maps.MapTypeId is undefined”在FF 14中使用GMAP3时
- chrome.storage.local["mykey"] is undefined
- 回调在 Angular2/Firebase 中生成“TypeError: this is undefined”
- KendoWindow .visible(); is undefined?
- jquery: $ is undefined
- ReactDom is undefined
- TypeScript: TypeError b is undefined
- rowdata is undefined
- mozChannels/mozSampleRate is undefined
- phonegap build cordova.file is undefined
- window.jQuery.ui is undefined
- blackberry.io.dir.appDirs is undefined
- Youtube iFrame API 'YT is undefined'
- SignalR $.connection is undefined
- “window.angular is undefined.” 当使用量角器进行自动测试时