Can we have different urls configured for same state in angularjs. For example,
I need to use /url-a and /url-b ,use same states in angularjs.
Yes indeed, a primitive way to get you started is just to double-up on your providers:
.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/url-a', {
templateUrl: 'url.html',
controller: 'UrlController',
})
.when('/url-b', {
templateUrl: 'url.html',
controller: 'UrlController',
});
Thanks for the reply.
I am using state provider and i guess if we use something similar, i get the following error,
Failed to instantiate module app due to:
Error: State ââ is already defined
.state(âapp.stateâ, {
url: â/url-aâ,
templateUrl: âurl.htmlâ,
controller: âUrlControllerâ,
})
.state(âapp.stateâ', {
url: â/url-bâ,
templateUrl: âurl.htmlâ,
controller: âUrlControllerâ,
})
To make this work, for each different url , i need to define a new state in config router like this,
.state(âapp.stateAâ, {
url: â/url-aâ,
templateUrl: âurl.htmlâ,
controller: âUrlControllerâ,
})
.state(âapp.stateBâ', {
url: â/url-bâ,
templateUrl: âurl.htmlâ,
controller: âUrlControllerâ,
})
Is there any way we can dynamically load the states, based on the url or any other solution?
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.