해결 함수가있는 Angular UI-Router를 사용하고 있지만 해결 함수를 축소하면 해결 함수 구문이 축소를 위해 올바르지 않기 때문에 전체 응용 프로그램이 중단됩니다. here으로 설명 된대로 String-Injection을 기반으로해야합니다. 나는 그것을 쓰는 방법을 모른다. 어떤 제안?각도 UI 라우터 축소 오류 - 문자를 기반으로 구문 해석을 변경할 수 있습니까?
// Resolves
var checkAuthentication = function($q, $location, $rootScope, Users) {
if ($rootScope.user) return true;
if (!$rootScope.user) {
var deferred = $q.defer();
Users.get(null, function(user) {
if (!user) {
window.location = '/';
return false;
}
console.log('User fetched: ', user);
$rootScope.user = user;
deferred.resolve();
}, function() {
window.location = '/';
return false;
});
return deferred.promise;
}
};
// Routes
angular.module('Dashboard').config(['$stateProvider', '$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
// For any unmatched url, redirect to '/'
$urlRouterProvider.otherwise('/dashboard');
// Now set up the states
$stateProvider
.state('dashboard', {
url: '/dashboard',
templateUrl: 'views/content/dashboard.html',
resolve: {
checkAuthentication: checkAuthentication
}
})
'.module ("Dashboard")'func의 나머지가 누락 되었습니까? 그렇지 않으면 닫는 대괄호가 없습니다. npt는 무엇입니까? – tymeJV
.config와 같은 방식으로 전달하지 않겠습니까? 배열로? –
tymeJV - .config 함수를 참조 용으로 두었습니다. 문제는 아닙니다. 문제는 checkAuthentication 함수의 구문에만 있습니다. – ac360