如何让它工作......
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/show/:id', {templateUrl: '/show/$ID', controller:'User'}).
otherwise({redirectTo: '/'});
}]);
将 $ ID 更改为:id
答案 0 :(得分:0)
重复。在这里查看我的答案: AngularJS - How to use $routeParams in generating the templateUrl?
var app = angular.module('app',[]);
app.config(
function($routeProvider) {
$routeProvider.
when('/', {templateUrl:'/home'}).
when('/users/:user_id',
{
controller:UserView,
templateUrl: function(params){ return '/users/view/' + params.user_id; }
}
).
otherwise({redirectTo:'/'});
}
);