Subverting a ui-sref with an ng-click in a ng-repeat. How?


#1

I’ve got a nice auto-populating list, being pulled from an array of objects, that works really nicely. Angular is great for this!

Here is the code:

<ion-item class="item-remove-animate item-avatar item-icon-right item-text-wrap mymenu" ng-repeat="item in menu" ui-sref="{{item.sref}}" ng-click="{{item.action}}">
    <h2>{{item.title}}</h2>
      	<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>

Simple I know, but I’m pleased with it.

The problem I have is this: Most of the items in the list are links to content based on the ui-sref. Some of them need to redirect to other content though.

For example - there is a Car section with it’s own menu choice, but also a Motorcycle menu choice. The Motorcycle information is in the Car information in this case and I just need a modal pop-up stating this, with a button to go to the Car section.

I can’t get the modal working. The code looks for a ui-sref so I have to put one in the array. This seems to override the modal. I’ve put a console.log in the modal code and it doesn’t even register the click.

Any ideas?


#2

add a condition --> if item.sref is set --> add dom node with ui-sref --> if item.action is set --> add dom node with ng-click.

There is no need to add both


#3

Can you show me how?