List item ng-click not working


#1

I’ve been reading here and seen that it seems to be resolved but in fact I’m trying this in navigator (chrome) and it’s not working (no alerts are shown):

  <ion-item ng-repeat="order in data.orders" ng-click="alert('me')">
    <h2>{{order.id}}</h2>
    <p>{{order.description}}</p>
  </ion-item>

How can I place icon-accessory on the right side of a Card Item
#2

It is looking for a scope variable called “alert”. It won’t work to directly put alert in the ng-click. Try defining a function in your controller that alerts and call that.


#3

well in fact that was a test, I’m trying to call a custom function:

<ion-item ng-repeat="order in data.orders" ng-click="loadOrder({{order.id}})">

In controller I’ve defined:

$scope.loadOrder = function loadOrder(orderId) {
};

Also I’ve noticed that this is working:

<ion-item ng-repeat="order in data.orders">
  <button ng-click="loadOrder({{order.id}})">Click me</button>
</ion-item>

Any way to achieve this? (don’t want to use href because is loading a different state and I would like to preserve history so I’m doing by code)


#4

Thanks @brandyshea, don’t know why but this is working:

<ion-item ng-repeat="order in data.orders" ng-click="loadOrder({{order.id}})" href="#">

#5

I have the same problem on iOS. It works well with ionic serve on my PC, but click event is not always triggered, with about 50% probability to trigger.
I tried with href="#" but found little difference. It works well for button but not for ion-item.


#6

I was also facing the problem, then i came to know that I have to use $scope for the function and both call and calling method should be in the same controller scope

$scope.hello = function() {
alert(“in”);
}

{{sms.mid.msg}}

#7

Thanks, work for me…