如何在 angularjs 中传递 $location.path 的参数
How to pass parameters for $location.path in angularjs?
单击按钮 我正在使用state.go((重定向到另一个页面。 代码是
$scope.usercal = function(x,y,z){
$state.go('app.calendar',{employeeName:x,employeeID:y,projectName:z});
}
我想对'$location.path(/url(;
但是如何传递参数呢?
嗨,
传递 $location.path 的参数,你应该像这样使用 $location.search((:
$location.path('/myURL/').search({param: 'value'});
这将导致
/myURL/?param=value
如果您的参数只是 url(路径(的一部分,则您可以使用
$location.path('/myURL/'+x+'/'+y);
如果参数是查询字符串,则使用
$location.path('/myURL/').search({employeeName: x});
我们使用ngRoute
,它的操作与ui-router
略有不同。
ui-router
中的$stateParams
被转换为 $routeParams
,它可以以相同的方式包含值,并像往常一样使用 url 填充,如下所示:
some/path/:a/to/dir/:b
结果是{a, b}
结果页面的参数。
相关文章:
- 正在使用$location.path(.)路由ng视图
- Angular JS$location.path(..)未启动路由控制器
- $location.path获取上一个路径
- Angularjs$location.path()无法定位到当前路由器
- AngularJS$location.path(path)最初未更新
- 为什么不't我的$location.path('test')更改地址栏
- AngularJS $location.path 无法按预期工作
- 在 $location.path() 更改后的另一个 ng-view 中触发事件
- $location.path() 在 facebook 登录后不起作用
- 调用 $location.path() 方法时,部分 url 被破坏了
- $location.path 不绑定角度 js 中的数据
- AngularJS和UI路由器:为什么$state.go()和$location.path()在交互式控制台中不起作用
- angularJS $location.path with parameters
- express 和 angularJs $location.path 不重定向到 /
- $location.path() 在 AngularJS 中不起作用
- AngularJS and location.path()
- angular js $location.path callback
- 如何在AngularJS中使用$location.path重定向转换之间的动画
- 使用$location.path()比较Angular中的URL
- 如何在 angularjs 中传递 $location.path 的参数