我想在cookieStore中存储一个变量,以访问另一个js文件。当我使用$cookieStore.put时,它会让我在说$cookieStore is undefined时出错。
我的代码:
var classFinder= angular.module('classFinder',['onsen.directives', 'ngTouch','ngCookies']);
classFinder.controller('courseController',['$cookieStore', function($scope,$window,$http,$cookieStore){
/**cookies**/
$cookieStore.put('myFavorite','oatmeal');
// Get cookie
var favoriteCookie = $cookieStore.get('myFavorite');
// Removing a cookie
$cookieStore.remove('myFavorite');
}]);我已经在html中包含了角曲奇的脚本。
发布于 2015-03-01 10:35:43
看看如何定义控制器:
['$cookieStore', function($scope, $window, $http, $cookieStore)您应该在数组中按相同的顺序拥有与函数中的参数相同的字符串。所以应该是
['$scope', '$window', '$http', '$cookieStore',
function($scope, $window, $http, $cookieStore)https://stackoverflow.com/questions/28792517
复制相似问题