I’ve been learning ui-router and I’d like to share some things I’ve learned that took me a while to get. With bits of Ionic Framework.
Let’s say you have an abstract state with a child and another state and you want to trigger a transition from the
controller to the other state. The following is a concrete example. I was building an ionic app that would grab a photo
from the phones photolibrary and transition to another view, passing the fetched uri to the new view.
Here we set up all the states in our app. Note that the ‘crop-image’ state is going to require an ‘:imageURI’ param in
The AppController is the main controller for this app. Accessible from any state inheriting from the app abstract
state declared in app.js. Notice how we are fetching a uri from the photolibrary and passing it as a parameter for the
CropController. We must first call encodeURIComponent() on this uri to pass the value around. Otherwise ui-router
get’s confused - loading CropController but failing to change the url or load the template.