【问题标题】:Passing a $scope variable into $state.href?将 $scope 变量传递给 $state.href?
【发布时间】:2017-07-15 02:28:06
【问题描述】:

下面是我控制器中的一个函数

$scope.getUrl = function() {
   $state.href('newState', 
    {randomId: $scope.randomId, anotherOne: $scope.anotherOne}
   );
};

上面的函数在模板中被这样调用(但当然不工作):

<div ng-href="{{getUrl()}}">

有没有办法将 $scope 变量从我的控制器传递到 $state.href?

感谢任何反馈

【问题讨论】:

    标签: angularjs parameters scope href state


    【解决方案1】:

    getUrl()返回您的值

    $scope.getUrl = function() {
       return $state.href('newState', 
          {randomId: $scope.randomId, anotherOne: $scope.anotherOne}
       );
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-28
      • 1970-01-01
      • 2015-10-17
      • 1970-01-01
      • 2020-01-24
      • 2012-02-13
      • 2014-09-05
      • 2011-10-13
      相关资源
      最近更新 更多