我是AngularJS的新手。我正在尝试在库克台上存储一个值,但要低于错误。
angularjs-1.2.14.js:9509 TypeError: Cannot read property 'put' of undefined
我的代码:
(function () {
'use strict';
var ivm = ivm || {};
angular
.module('ivm', ['ivml.chart', 'ngCookies'])
.run(run);
run.$inject = ['$rootScope', '$location', '$cookieStore', '$http'];
function run($rootScope, $location, $cookieStore, $http) {
// keep user logged in after page refresh
$rootScope.xaxis_length = $cookieStore.get('xaxis_length') || {};
}
var ivm = ivm || {};
ivm.visualElements = ivm.visualElements || {};
ivm.visualElements.Bars = function Bars(chartController, barController, $timeout, $cookieStore, $rootScope) {
var Bars = {
elements: {
chartController: chartController,
barController: barController,
$timeout: $timeout,
xscale: null,
yscale: null,
svg_g: null,
frame: null,
index: -1
},
attributes: {
fill: "black", //@i fill color of the bar
fillOpacity: 1, //@i fill opacity of bar
stroke: null, //@i color of the bar's outline
strokeWidth: 1, //@i stroke width of the bar's line
strokeOpacity: 1, //@i opacity of the bar's outline
thickness: 5 //@i the bar's thickness (size parallel to the dependent dimension)
},
accessors: {
data: [], //@ir javascript object to plot
positionFunction: null,//@ir accessor for the bar's position on the nominal axis
valueFunction: null //@ir accessor for the the bar's value (size and direction)
},
events: {
mouseOverE: null, //@e mouse over event
mouseOutE: null, //@e mouse out event
clickE: null //@e mouse click event
}
}
var xaxis_length = "0";
console.log(xaxis_length);
$cookieStore.put('xaxis_length',xaxis_length);
我在put
无法阅读的上线遇到错误。
我在哪里犯了错误?我的代码中有许多功能,我只粘贴了一个函数,其中有错误。
您需要和run
块一样,将$inject
属性添加到您的控制器中,并且
ivm.visualElements.Bars.$inject
= ['chartController', 'barController', '$timeout', '$cookieStore', '$rootScope'];