user2934433 user2934433 - 4 months ago 7
jQuery Question

Angular js Controller method from HTML with a parameter

Could someone please help me in dealing the below situation.

I have an accordion, on click of accordion it expands.

Depending on header clicked I would like to load the data, or even preload the data.

I have a function in controller with below signature

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


Accordion is as follows

<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>

Answer

From your question, looks like you want to display the data on click of the header? Just do this

<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>

And in the controller you would get 'x', so show the details based on x.

Comments