5

I have tried to do the following:

<accordion-heading ng-click="doSomething(); isopen=!isopen">

Should this work? or is it not possible to string there call together?

ng-click="doThis(param); doThat(param);"

I just need pointed in the right direction :-)

EDIT:

this:

ng-click="doThis(param); doThat(param);"

works as expected, I think it is:

isopen=!isopen

that is causing the problem, I realise I didn't say this initially.

I go around this by adding an extra div into the accordion heading, like this:

<accordion-heading ng-click="isopen=!isopen">
    <div ng-click="showMainView()">
        <i class="glyphicon" ng-class="{'glyphicon glyphicon-minus': isopen, 'glyphicon glyphicon-plus': !isopen}"></i>
        {{item.model}}<br>{{item.model_engine}}
    </div>
</accordion-heading> 
mcneela86
  • 1,029
  • 3
  • 18
  • 35

2 Answers2

3

possible !! possible !! possible !! possible !! possible

You can call multiple functions with ';'

See here

Using ng-click to call two different functions

How to add many functions in ONE ng-click?

How to use ng-click with multiple expressions?

Community
  • 1
  • 1
1

It works:

http://plnkr.co/edit/fwSdBT3NIBrlk80aTgaB?p=preview

However be careful not to do too much logic in there. You should put the logic in the controller and only call it from the view. (isopen = !open for example doesn't belong on the view)

haimlit
  • 2,572
  • 2
  • 22
  • 26