문제

저는 Hot Towel 각도 라이브러리(https://github.com/johnpapa/hottowel-angular-bower) 선임 개발자로부터 물려받은 프로젝트에 대해.

또한 Angular용 Auth0의 인증 라이브러리도 통합하고 있습니다.

일부 경로를 인증된 사용자로 제한해야 합니다.이를 위해 몇 가지 경로 속성을 설정했습니다.
isLogin: true 인증되지 않은 사용자로 제한된 경로의 경우.
requiresLogin: true 인증이 필요한 경로의 경우, 그렇지 않은 경우에는 그 반대입니다.각 런스루에서 이러한 속성을 확인하기 위해 다음을 사용합니다. $rootScope.$on('$routeChangeStart' function()).

app.run(function ($rootScope, $location, auth, common, config) {
    var getLogFn = common.logger.getLogFn,
        log      = getLogFn('auth handle'),
        events   = config.events;

    $rootScope.$on('$routeChangeSuccess', function (e, nextRoute, currentRoute) {
        if (nextRoute.$$route && nextRoute.$$route.settings && nextRoute.$$route.settings.requiresLogin) {
            if (!auth.isAuthenticated) {
                $location.path('/login');
                log('User not authenticated');
            }
        }
        if (nextRoute.$$route && nextRoute.$$route.settings && nextRoute.$$route.settings.isLogin) {
            if (auth.isAuthenticated) {
                $location.path('/');
                log('User is authenticated');
            }
        }
    })
});

이제 이것이 Hot-Towel에 포함된 스피너 기능을 방해하는 것 같습니다.Shell.js에서 다음을 찾습니다.

$rootScope.$on('$routeChangeStart',
    function (event, next, current) { toggleSpinner(true); }
);

$rootScope.$on(events.controllerActivateSuccess,
    function (data) { toggleSpinner(false); }
);

$rootScope.$on(events.spinnerToggle,
    function (data) { toggleSpinner(data.show); }
);

무슨 일이 일어나면 스피너는 결코 회전을 멈추지 않는다는 것입니다(예:vm.isBusy = 컨트롤러가 활성화되지 않고 이를 재설정하기 때문에 true), 이 문제를 어떻게 해결합니까?

도움이 되었습니까?

해결책

하나의 아이디어는 이벤트 ($ 브로드 캐스트)를 사용하여 유엔 승인 된 액세스가 이루어 지도록 통지하여 회 전자를 끄는 컨트롤러가 수신하는 것입니다.

다른 팁

나는 당신의 코드를 오랫동안 연구하지 않았지만 사용해서는 안됩니까? $routeChangeSuccess 스피너를 멈추려고?

$scope.isViewLoading = false;
$scope.$on('$routeChangeStart', function() {
    $scope.isViewLoading = true;
});
$scope.$on('$routeChangeSuccess', function() {
    $scope.isViewLoading = false;
}); 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top