Issue originally was trying to set the parameters in the url correctly, however, this post solved it: How can I set a query parameter in AngularJS without doing a route?
Then a new problem arose. When setting the url in the controller,
$scope.view = function(itemtmpl) {
// change path and add parameter 'id' to the url
$location.path('/itemtemplates/view/').search('id', itemtmpl.itemdefnid);
// also tried with $routeProvider
$location.url('/itemtemplates/view/' + itemtmpl.itemdefnid);
};
the item's ID is interpreted as separate arguments, not one number (the url will be used to make a REST call in a factory, so it has to be a single argument).
That's the primary problem.
I thought there was a problem with my $location usage, so I went to the AngularJS docs: https://docs.angularjs.org/api/ng/service/$location
Still no luck.
$routeParams variable print out says that parameters are set accordingly.
Another idea I may need clarified is why my page's config will only recognize the $location.url when it's just appended to the end view/1000
, not if it's a parameter view/?1000
and still won't proceed if it has an id view/?id=1000
.config(function($routeProvider) {
$routeProvider.when('/itemtemplates/view/:id', {
templateUrl: 'itemtemplates/add/main.tpl.html',
controller: 'ViewCtrl'
});
})
What could I be missing? Thanks in advance.