2016-09-09 2 views
0

경로를 가져 오는 링크의 색을 변경하려고 시도했지만 작동하지 않지만 원하는 방식이 아닙니다.Angular.js 활성 탐색 요소

내가 http://localhost:8000/projects.html 바로 벌금이다 :

무엇인지 지금 일어나고있는 것은 이것이다?

집에가는 것처럼 다음 링크를 클릭하면 : 내가 말하는 것을 이해 http://localhost:8000/index.html 대신 http://localhost:8000/projects.html#/index.html

:

http://localhost:8000/projects.html#/index.html 내가이 링크로 이동하려면? 이 문제를 어떻게 해결할 수 있습니까? 고맙습니다.

App.controller('NavCtrl', ['$scope', '$location', function($scope, $location) { 
    $scope.items = [ 
     {path: '/index.html', title: 'Home'}, 
     {path: '/projects.html', title: 'Projects'}, 
     {path: '/contributions.html', title: 'Contributions'}, 
    ]; 
    $scope.isActive = function(item) { 
     if (item.path == $location.path()) { 
     return true; 
     } 
     return false; 
    }; 
    }]) 
    .controller('MyCtrl1', [function() { 
    }]) 
    .controller('MyCtrl2', [function() { 
    }]); 

HTML을 app.js :

<div id="navbar" class="navbar-collapse collapse"> 
     <ul class="nav navbar-nav" ng-controller="NavCtrl"> 
     <li ng-repeat="item in items" ng-class="{active: isActive(item)}"> 
      <a href="#{{item.path}}">{{item.title}}</a> 
     </li> 
     </ul> 
</div> 
+0

응용 프로그램 내에서 페이지 수준 탐색 기능을 제공하려는 경우 ngRoute 및 ui-router가 작동하는 방식을 살펴볼 수 있습니다. – mindparse

답변

0

는 HTML5 모드 (SPA 응용 프로그램)를 활성화 하시겠습니까? answer

또는 SPA없이 리디렉션 하시겠습니까? 마지막으로 html5mode = true 및 target = "blank"를 사용하십시오.

+0

감사합니다. 그게 내 코드에 있는거야? 너 나 좀 도와 줄 수있어? –

+0

App.config ([ '$ locationProvider', function ($ locationProvider) {$ locationProvider.html5Mode (true);}]) –