在AngularJS路线传递多个参数多个、路线、参数、AngularJS

由网友(窒息的伤)分享简介:我想实现它应该有多个参数的角度路线。这里是什么我想一个例子:I am trying to implement a angular route which should have multiple parameters. Here is an example of what I tried: .when('/myRo...

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

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';
阅读全文

相关推荐

最新文章