$ionicLoading in place of toast - ng-click not working?


#1

I was using $cordovaToast but I’ve been forced to switch to something non-native in order to embed a link with a click target in a status message. Basically, my use case is displaying a “action completed | undo” option similar to what’s in Google’s Gmail app (see https://github.com/soarcn/UndoBar) Has anyone else tried this? I basically just modified the css to bottom-position the toast and restyled it a bit.

My issue right now is that I can’t seem to get an ng-click inside the template wired up to work with a function on the local scope. Here’s my code, note the scope option on show(). The function in question is never called:

$ionicLoading.show({ templateUrl: 'templates/ok-undo-action.html', scope: $scope, noBackdrop: true, duration: 2000 });

And the corresponding template:

<span>
  Something happened
  <a ng-click="undo()">
    <i class="icon ionicon ion-arrow-return-left"></i>
    Undo
  </a>
</span>

Any suggestions very much appreciated.


#2

Not sure but I think “a” tag doesn’t work with ng-click.
Did you try to put a button instead?


#3

Doesn’t seem to make a difference. ng-click isn’t binding. No function undefined warnings, etc.


#4

I will ask a stupid question :smile:
Did you have ng-app directive?


#5

Well it’s in an Ionic app. So yes, there’s an ng-app on the body tag as usual?


#6

Passing scope still doesn’t seem to work… hmm.