1
각도 ui 라우터가 새로 도입되었습니다.해결 상태의 Angularjs 루트 스코프
로컬 .json 파일에서 설정을로드하는 데 문제가 있습니다.
app.run()의 설정을 $ rootscope.settings에 저장합니다.
.run(['$rootScope', '$http', '$state', '$stateParams', function ($rootScope, $http, $state, $stateParams) {
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
$http.get('./App/Core/Config/config.json').success(function (data) {
$rootScope.settings = data;
});
}])
$ state로 가기 전에 $ rootscope.settings에서 데이터를 가져와야합니다. 그러나 해결에 $ rootscope.settings underfined입니다.
.state('alertcenter', {
url: '',
views: {
'alertcenter': {
templateUrl: './App/Features/AlertCenter.html',
controller: 'AlertCenter'
}
},
resolve: {
Data: ['$http', function ($http) {
return $http({
method: 'GET',
url: $rootScope.settings.baseUrl + '/getData',
withCredentials: true
});
}]
}
});
어떻게하면 $ 상태를 해결 한 설정에 액세스 할 수 있습니까? 아니면 더 좋은 방법이 있습니까?
코드를 plnkr에 넣으시겠습니까? – user3722785