在下面的代码中,我登录到控制台 $rootScope 并记录未定义。为什么会这样?
$scope.init = function ($rootScope) {
// var s = $cookies.get("arr");
// var ex = [];
var ex = $cookies.get("arr");
$scope.arry = JSON.parse(ex);
alert("scooe.arry" + $scope.arry);
console.log("JSON.stringify($cookies.get('arr'))=" + $scope.arry);
//create a call to google api for all stocks in the $scope.arry
$scope.arry.forEach(function(entry) {
console.log("entry is " + entry);
var v = httpcall.getVal(entry);
$scope.arry.push(v);
//console.log("rootscoooope =" + $rootScope.share + "==");
console.log($rootScope); debugger;
});
init 函数由名为 NameCtrl 的控制器的 ng-init 调用。
<ul>
<li ng-repeat="sr in arry track by $index"> value : {{sr.l_cur}}
<a href='#' onhover="remove" ng-click="removename(sr)"> (-)</a>
</li>
</ul>