Twitter dynamic links boot navbar in angularjs

I created an angular app that uses Twitter upload.

I would like dynamic links in the navigation bar (for example, ng-href="#/{{course.id}}"

They never display - they end as href="#/"

If I placed the navigation bar inside the <div ng-view> section of the page that they execute, although I would prefer not to place it there, since I do not want to duplicate it on each partial.

The main page is laid out as follows:

 <html ng-app="studentApp"> <head> links to cdns here</head> <body> <div class="container-fluid"> <div class="navbar navbar-inverse navbar-fixed-top">Dynamic bar here</div> <div ng-view>Partials in here</div> </div> </body> </html> 

For all partial elements that are loaded in the ng-view part, interpolation occurs as expected, but not in the navigation bar.

I created Plunker, not trying to include everything here. ( http://plnkr.co/MK8QEDQUVawkOi92xJXk ).

+6
source share
1 answer

Angular will only work inside ng-view, once you start using routing.

I have only this on the content page:

 // links to cdn, js, css <body> <div id="app-container" ng-app="dashboard" ng-view></div> </body> 

All partial elements are displayed inside the div.

All partial parts include partial navigation at the very top:

 <div ng-include src="'html/navigation.html'"></div> 

navigation.html has its own controller:

 <div id="nav-bars-container" ng-controller="NavCtrl"> <a href="#/{{course.id}}">Foo</a> </div> 

& thus has its own reach. Others may be introduced:

 function NavCtrl($scope, $route, $routeParams) { console.log($routeParams); $scope.course.id = $routeParams.id; } 
+6
source

Source: https://habr.com/ru/post/944073/


All Articles