如何在角度js中获取url参数
16lz
2021-01-22
Here's my url
这是我的网址
localhost/project/#/showprofile/18
I want to display the parameter 18
in my view
我想在视图中显示参数18
In the app.js
i have
在app.js我有
.when('/showprofile/:UserID', {
title: 'Show User Profile',
templateUrl: 'views/layout/showprofile.php',
controller: 'authCtrl',
})
Here the page showprofile.php
is displaying, but suddenly the url goes like this
在这里显示showprofile.php页面,但突然网址就像这样
localhost/project/#/showprofile/:UserId
How can i get the value 18
inside the showprofile.php
and make the url as it is i.e.,
如何在showprofile.php中获取值18并使其成为原样,即,
localhost/project/#/showprofile/18
3 个解决方案
#1
2
Use $routeParams
to get the parameter value:
使用$ routeParams获取参数值:
$routeParams.UserID
Make sure you inject $routeParams
before using it.
确保在使用之前注入$ routeParams。
EDIT How can i get the value 18 inside the showprofile.php
编辑如何在showprofile.php中获取值18
<?php
$link = $_SERVER['PHP_SELF']; // Get current URL
$link_array = explode('/', $link); // Split by /
echo $page = end($link_array); // Get last element from array
?>
更多相关文章
- 使用包含特定号码的网址重定向到索引
- 如何使用Javascript ajax发送网址? [重复]
- 如何添加动态参数
- 根据网址上的国家/地区将用户重定向到正确的数据库,我使用i18n fo
- 在php中获取引荐来源网址(包括参数)
- php通过$_SERVER['HTTP_USER_AGENT']获取浏览器相关参数
- PHP Word上的短网址
- MYSQL5.5和5.6参数的差异
- 存储过程,参数数量不正确bug?