这是我的js代码
var MYApp = angular.module('myApp', ['ngRoute', 'myAppServices', 'ngSanitize'])
.config(myRouter);
angular.module('myAppServices', ['ngResource'])
.factory('GridsAPI', function($resource) {
return {
GetUser: $resource('/MY/system/getUser/:id')
};
});
function ViewUserController($scope, user) {
}
function myRouter($routeProvider) {
$routeProvider
.when('/users/view/:id', {
templateUrl: '/MY/system/users/view/:id',
controller: 'ViewUserController',
resolve: {
user: function(GridsAPI) {
//how to return user based on id passed to this url?
}
}
});
}
我想在视图加载之前通过 ajax 调用获取用户,如何在解析中获取 id 参数?