本文介绍了在AngularJS路线传递多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现它应该有多个参数的角度路线。这里是什么我想一个例子:

I am trying to implement a angular route which should have multiple parameters. Here is an example of what I tried:

.when('/myRoute/paramA/:paramA/paramB/:paramB/paramC/:paramC', {
    templateUrl: 'abc.html',
    controller: 'pwrController as pwrCtrl'
});

现在这个问题是我需要总是传递paramA上以通paramB。和paramA上和paramB为了通过paramC。

Now the problem in this is that I need to always pass paramA in order to pass paramB. And paramA and paramB in order to pass paramC.

有没有棱角任何方式在那里我可以通过paramA上,paramB或paramC独立?

Is there any way in angular where I can pass paramA, paramB or paramC independently ?

感谢。 !

推荐答案

注射 $位置到您的控制器和用它来代替routeParams

inject $location into your controllers and use that instead of routeParams

var paramA = 'something';
$location.search('paramA', paramA); // write
// result http://localhost:3000/#/route/routeParam?paramA=something

$location.search() // read whole object
$location.search().paramA // read one parameter
// result 'something';

这篇关于在AngularJS路线传递多个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 18:32