I am facing an issue with setting the state through a controller while parsing only 1 parameter. It seems like the preferred state is called, but then the "otherwise" state is loaded right after. Interestingly, I noticed that the preferred state was being triggered when hitting the back button. The small problem in my stateprovider settings is eluding me.
Here is a snippet from my controller.js file:
.controller('resultsCtrl', ['$scope', '$stateParams', 'searchfactory', '$state',
function ($scope, $stateParams, searchfactory, $state) {
$scope.results = searchfactory.getresults();
console.log($scope.results);
$scope.showdoc = function(docid){
console.log(docid);
$state.go('doctor', { docid: docid });
}
}])
.controller('doctorCtrl', ['$scope', '$stateParams',
function ($scope, $stateParams) {
alert($stateParams.docid);
}])
And here is part of my routes file handling the "doctor" section:
.state('doctor', {
url: '/doctor/{docid}',
templateUrl: 'templates/doctor.html',
controller: 'doctorCtrl'
})
When I click the back button, the URL displays as , which seems correct to me. Additionally, the alert pops up and redirection happens after clicking "ok" on the alert.
Your assistance would be highly appreciated.