I'm beginning to convert a large web application, with a lot of complex JQuery DOM manipulation and an ASP.NET MVC backend, into something more manageable. I'm converting the server-side code into a REST API, and I want to use AngularJS to drive the UI.
I'm starting by converting one area of the app over, which consists of three screens. Making a selection in one screen presents you with a new set of choices, and you can move forward and back. I've managed to achieve this behavior very cleanly by using routes; each choice is a link with href='#/something...'
, and this causes a change in UI state by loading a different controller/template.
I'm now trying to animate this transition. The ng-animate
attribute gets me most of the way there with the enter
and leave
options, but these actually fire at the same time! The result is visually very confusing. What I'd ideally want is a clean way to manage the following sequence of events:
I can achieve this without animation by using the resolve
parameter to the $routeProvider
, but I don't know how to make the animation work properly! What is the correct to manage this kind of state?
You can write your own code that will implement animation as described here: http://code.angularjs.org/1.1.4/docs/api/ng.directive:ngAnimate
So perhaps it is possible to do it like this:
How monitor the flag? You can simply watch global variable with setTimeout, but this is kind of ugly. I think this would be much better to use some sort of pub/sub mechanism that would allow you to subscribe to "data ready" event. For example, I use postal.js and is quite satisfied with it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.