奇怪的问题,我无法访问在 CtrlA 中设置的 CtrlB 变量中的 $rootScope。
HTML:
<div role="main" class="container_9" ng-controller="CountryCtrl" ng-init="updateToken('<?php echo $TOKEN; ?>')">
CtrlA
app.controller('CountryCtrl', function ($scope,$rootScope, $http) {
$scope.updateToken = function(token) {
$rootScope.token = token;
}
});
CtrlB
app.controller('DealerListCtrl', function ($scope, $http, $rootScope, dealerService) {
$scope.dealer = [];
$http.get('files/framework/dealer/'+ $rootScope.token).success(function(data) {
$scope.dealerall = data;
});
//$scope.dealerall = dealerService.api.get({token: $scope.token});
$scope.orderProp = 'name';
});
错误信息:
/framework/dealer/undefined 500 (Internal Server Error)
我究竟做错了什么?
更新
Plunker 代码:
http ://plnkr.co/edit/r559zyMKjA64xSdmrTem
跑不动了……