这是我的 Controller 代码
.when('/showprofile/:UserID', {
templateUrl: 'resources/views/layout/showprofile.php',
controller: 'ShowOrderController',
})
我正在通过 url 传递参数。
我正在尝试像这样直接通过 url 访问此页面
http://192.168.1.58/myapp/#/showprofile/8
但它正在将我重定向到
http://192.168.1.58/myapp/#/showprofile/:UserID
如何在我的 View 中获取 url 值?
这是我的 app.js这是我的 authCtrl.js
最佳答案
在你的 Controller 中试试这个,它会返回基于 url 值的对象然后我们可以像这样得到尊重的值
//it will return the object
console.log($routeParams);
//get the specific url value like this
console.log($routeParams.UserID);
or
console.log($route.current.params.UserID);
关于javascript - AngularJS - 页面在尝试从 url 获取参数时重定向到 angular js 中的其他页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31560652/