Thursday, 12 September 2013

angularjs: server route when ng-view is on page

angularjs: server route when ng-view is on page

Is there any way to have some links on the page feed the ng-view container
while others load the page from the server? See this fiddle for example:
http://jsfiddle.net/terebentina/Wy7Ww/
html:
<div ng-app="test">
<a href="/">tab1</a>
<a href="/tab2">tab2</a>
<a href="/logout">logout</a>
<div ng-view></div>
</div>
js:
angular.module('test', []).config(function($routeProvider,
$locationProvider) {
$routeProvider
.when('/', {
template: 'tab1'
,controller: 'TabCtrl'
})
.when('/tab2', {
template: 'tab2'
,controller: 'TabCtrl'
});
$locationProvider.html5Mode(true);
})
.controller('TabCtrl', function() {});
Basically I want the logout link to go to server while the 2 tabs to feed
the ng-view. As you can see, I only defined the tab routes in angular and
no 'otherwise' section but it still tries to load logout in the ng-view.

No comments:

Post a Comment