我正在研究 Angularjs,我遇到了奇怪的问题,我无法使用 $routeParams 从 URL 获取参数值。
var MyApp = angular.module('testAngularApp', ['ngRoute','ngResource'])
.config(['$routeProvider',
function ($routeProvider) {
$routeProvider.
when('/', {
when('/updateUser/:id', {
templateUrl: 'Pages/User/Edit.html',
controller: 'UpdateUserCtrl'
})
}]);
控制器
angular.module('testAngularApp').
controller('UpdateUserCtrl', ['$scope', 'updateUserService', '$http','$route', '$routeParams', function ($scope, updateUserService, $routeParams,$route, $http) {
$scope.testV = "Update User Ctrl";
console.log("hello");
$scope.params1 = $routeParams.id;
console.log($routeParams.id ); //i am getting undefined
console.log($scope.params1); //i am getting undefined
var check = $routeParams['id'];
console.log(check); //i am getting undefined
}]);