我试图在解析1个参数时通过控制器设置状态。据我所知,首选的状态是调用,但是“否则”状态是紧接着加载的。我发现首选状态是通过点击后退按钮来调用的。单击“后退”按钮时,将调用首选状态。在我的状态提供程序设置中似乎是一个小问题,但我就是找不到它。
下面是我的controller.js文件的一部分。
.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);
}])下面是我的路径文件,处理"doctor“部分。
.state('doctor', {
    url: '/doctor/{docid}',
    templateUrl: 'templates/doctor.html',
    controller: 'doctorCtrl'
  })点击后退按钮后,url显示为http://192.168.8.100:8100/#/doctor/11,我认为这是正确的url。此外,警报也会弹出。在警报上点击"ok“按钮后,重定向就完成了。
非常感谢您的帮助。
发布于 2017-02-20 16:41:00
检查是否存在templates/doctor.html exist或href。
https://stackoverflow.com/questions/42328140
复制相似问题