如何将ui-sref url传递给ng-click功能

时间:2017-04-12 09:09:20

标签: angularjs

<td class="text-left">
  <a class="curosr" ui-sref="private.Registered_details ({uid: 
   x.userID,vid:x.vehicleID,page_value:'page1'})" ng-
   click="linkClick(x.name,0,Registered_details/uid/vid/page_value)">{{x.name}}
  </a>
</td>

在上面的代码段中,我有一个ui-sref =“private.Registered_details({uid:    x.userID,vid:x.vehicleID,page_value:'page1'})“..如何通过ng-click传递这个网址到linkClick功能

1 个答案:

答案 0 :(得分:0)

ng-click像这样。传递导航到您选择状态所需的所有详细信息。

<td class="text-left">
  <a class="curosr" ng-click="navigateToDetails(x)">{{x.name}}
  </a>
</td>

在控制器中,首先将$state作为依赖项注入,然后使用$state.go导航到该状态。

$scope.navigateToDetails = function(x) {
  // some amazing code to decide whether or not to navigate
  $state.go("private.Registered_details", {
    uid: x.userID,
    vid: x.vehicleID,
    page_value:'page1'
  });
}