简体   繁体   English

使用查询字符串将值从路由传递到视图模板

[英]Passing values from a route using query string to the view template

There are certain $scope 's values which contains string values in it and declared inside one controller. 有一些$scope的值,其中包含字符串值并在一个控制器中声明。 These $scope values are fetched from a view template and stored inside it. 这些$scope值是从视图模板中获取并存储在其中的。

I want to pass these $scope 's values to the same view template but on different div of the template. 我想将这些$scope的值传递到相同的视图模板,但在模板的不同div上。

How is it possible to pass it using query string using angular routing. 如何使用角度路由使用查询字符串传递它。

Remember: 记得:

  1. view Template 查看模板
  2. controllers 控制器

Routes the same template with different urls 使用不同的URL路由相同的模板

I prefer to pass using ngHref: 我更喜欢使用ngHref传递:

<a ng-href="#/myRoute/{{myId}}">link1</a>

or, of course, you can do the same thing using $window.location: 或者,当然,您可以使用$ window.location做同样的事情:

$window.location = '#/myRoute/' + $scope.myId;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM