2016-08-15 3 views
0

이 코드에서 도움을 요청하고 싶습니다. 그렇지 않다면 PARAM의 어쩌려 구`t 작업 때문에, 왜,AngularJS 그렇지 않으면 작동하지 않습니다.

Error: No default engine was specified and no extension was provided. 

: 나는 존재하지 않는 주소로 갈 때

app.config(function ($locationProvider, $routeProvider) { 

    $locationProvider.html5Mode({ 
     enabled: true, 
     requireBase: false 
    }); 
    $routeProvider 
     .when("/", { 
     templateUrl: "views/home.html", 
     controller: "HomeController" 
    }).when("/login", { 
     templateUrl: "/views/login.html", 
     controller: "LoginController" 
    }).when("/register", { 
     templateUrl: "/views/register.html", 
     controller: "RegisterController" 
    }).when("/users", { 
     templateUrl: "/views/admin/users.html", 
     controller: "UserController", 
     requiresAuth : true 
    }).otherwise({ 
     redirectTo: "/" 
    }); 
}).run(function($rootScope, Session) { 
    $rootScope.$on("$routeChangeStart", function(event, next, current) { 
    if (next.requiresAuth && !Session.getIsAdmin()) { 
     alert("You are not authorized"); 

     event.preventDefault(); 
    } 
    }); 
}); 

그것은 잘못을 보여줍니다?

답변

2

이 오류는 각도가 아닌 서버에서 발생합니다. 이 "존재하지 않는"주소에 대해 index.html 페이지를 제공하도록 서버를 구성해야합니다 (그리고 기존의 주소도 모두 BTW.Read Understanding what it takes to remove the hash # from angular routes).

HTML 페이지가없고 응용 프로그램이 없으면 Angular는 아무 것도 할 수 없습니다. index.html이 서버에서로드되면 각도 응용 프로그램이 시작되고 URL이 무엇인지 검사하고 경로와 일치하지 않는 것을 감지 한 다음 홈 페이지로 리디렉션합니다.

+0

물론 가능합니다. 멍청한 실수. 모든 것은 괜찮습니다. 고맙습니다 – Kuba

관련 문제