I have a hierarchy loaded from rest service, that contains site tree. Each tree item has a FriendlyUrl property, which should tells angularjs what content to display for specific URLs. Since url data is dynamic, I configured a single route xin my application:
.state('default', {
templateUrl: 'm/templates/app.html',
url: '/*path',
resolve: {
FriendlyUrl:
['$stateParams'
function ($stateParams) {
var path = $stateParams.path;
}],
},
controller: 'appCtrl',
})
Then in my appCtrl controller, I check for injected FriendlyUrl and display appropriate data in appropriate places. The actual code is slightly bigger, but I stripped some code for readability.
I have a problem when I try to navigate to a different url. When a user clicks on a certain anchor, I would like to navigate to a different url within the same application to load different content.
I tried using
$state.go('default', {
path: 'about-us'
}, {
location: true,
inherit: false
});
but when I execute the above code several times I get: /#/about-usabout-usabout-us
Also, I cannot use '/' symbol, when I replace '-' with '/' the execution completes without navigating and without any errors.
I would like to be able to navigate to hash urls like this for example:
/#/company/about-us/contacts