1.0.4 • Published 8 years ago

umanit-ionic-view v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

umanit-ionic-view

Directive to manage Ionicframework view events in the template

Installation

Via npm :

npm install --save umanit-ionic-view

Via bower :

bower install --save umanit-ionic-view

Now inject the module umanit-view in your angular application.

Why ?

In Ionicframework, every view is cached by default. So, if you want to use a function when your view is loaded, you can't rely on ngInit directive to do it, because it will be only fire once.

At this step, 2 options :

  • Adding the option cached="false" to your ionic-view directive and the whole view will not be cached.
  • Using Ionic view events to call your function

With the last method, one problem : what happens if you have one controller for multiple views ? So here we are !

How to use

Just add 2 attributes to your ionic-view directive like that :

<ion-view view-title="My title" umanit-view on-before-enter="callMe()">

You have to add umanit-view (in order to call the directive), and then the event on which you want to bind your action (here on-before-enter is for $ionicView.beforeEnter event)

All available attributes are :

  • on-loaded
  • on-enter
  • on-leave
  • on-before-enter
  • on-before-leave
  • on-after-enter
  • on-after-leave
  • on-unloaded