I am using angular ui routing to route my modules. I know if i add something like "url: '/:campKey'," in my state then this will come in the browsers url. But instead i am using params as an array of parameters, it is not possible to have both url and params. So how do i show my campkey in the url in the browser. Thanks
.state('_.work.inside.content', {
views: {
"": {
controller: 'InsideContentCtrl',
templateUrl: 'app/work/inside/content.html'
}
},
params: ['campKey', 'from', 'to'],
data: {menu: { isHidden: true }},
resolve: {metric: ['$http', '$stateParams','appName', 'dateFilter', function($http, $stateParams,appName, dateFilter) {
if($stateParams.campKey) {
return $http({
method: 'GET',
url: '/-/api/' + appName + '/campaign/' + $stateParams.campKey +'/inside-content',
params: {from: dateFilter($stateParams.from, 'yyyy-MM-dd'), to: dateFilter($stateParams.to, 'yyyy-MM-dd')}
}).
success(function(resp, status) {
return resp.results;
})
.error(function(err) {
console.log(err);
throw err;
});
}
}]}
});
after searching some more i found out that instead of using 'params' as above. I can use url and get my 'campkey' in the browsers url. But i would have to remove 'params'. The changes would be as below.
.state('_.work.inside.content', {
url: '/:campKey',
views: {
"": {
controller: 'InsideContentCtrl',
templateUrl: 'app/work/inside/content.html'
}
},
data: {menu: { isHidden: true }},
resolve: {metric: ['$http', '$stateParams','appName', 'dateFilter', function($http, $stateParams,appName, dateFilter) {
if($stateParams.campKey) {
return $http({
method: 'GET',
url: '/-/api/' + appName + '/campaign/' + $stateParams.campKey +'/inside-content',
params: {from: dateFilter($stateParams.from, 'yyyy-MM-dd'), to: dateFilter($stateParams.to, 'yyyy-MM-dd')}
}).
success(function(resp, status) {
return resp.results;
})
.error(function(err) {
console.log(err);
throw err;
});
} }]}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments