Angular js带有参数的HTML控制器方法

时间:2016-07-06 07:31:56

标签: javascript jquery html angularjs angular-ui-bootstrap

有人可以帮我处理以下情况。

我有手风琴,点击手风琴它会扩大。

根据点击的标题,我想加载数据,甚至预加载数据。

我在控制器中有一个带有以下签名的功能

$scope.getDetailsFn = function(Id){
    $scope.Details = "I am possible"
};

手风琴如下

<uib-accordion close-others="oneAtATime" >
   <uib-accordion-group heading="{{x.id}}" ng-repeat="x in xs" >
      //Is the below possible or calling the below on ng-click possible
      {{getDetailsFn({{x.id}})}}
      {{Details}}
      Message: {{x.message}}
      </br>
   </uib-accordion-group>
</uib-accordion>

1 个答案:

答案 0 :(得分:1)

从您的问题看,您希望在点击标题时显示数据?就这样做

<uib-accordion close-others="oneAtATime" >
 <uib-accordion-group heading="{{x.id}}" ng-repeat="x in xs" ng-click="getDetailsFn(x.id)">
  {{Details}}
  Message: {{x.message}}
  </br>
 </uib-accordion-group>
</uib-accordion>

在控制器中你会得到&#39; x&#39;所以根据x显示细节。