Reputation: 129
I have page with ng-view
. This page is generated by php following URL: www.sbt.com/profile
What url I need to set in href
attribute, that will work Angular JS by url:
www.sbt.com/profile/privacy/1
I tried:
.when('/profile/:page/:type', {}
And link like as:
<a href="#profile/privacy/1">Go</a>
But it does reload page at url when I click to link in page /profle
:
www.sbt.com/#/profile/personal/1
Full code is:
.config(function ($locationProvider, $routeProvider) {
$routeProvider
.when('/profile/:page/:account', {
templateUrl: function(params) {
return '/public/html/personal.html';
},
controller: 'EditProfileController'
})
/* Chat */
.when('/chat/dialog/:id', {
controller: 'ChatController'
});
})
Upvotes: 2
Views: 503
Reputation: 193301
If your angular application is served from the page with base URL like /profile
then links should look like:
<a href="#/privacy/1">Go</a>
and route configuration should be
.when('/:page/:account', {
templateUrl: function(params) {
return '/public/html/personal.html';
},
controller: 'EditProfileController'
});
Also make sure you define base href (although it should work without it too in your case). Put this script in the <head>
of the page:
<script>
document.write('<base href="' + document.location + '" />');
</script>
Upvotes: 1