How to avoid template repainting when I get back to the route in Angularjs UL router

In the current version, when I switch, say the state is 'a' to indicate 'b', and then go back to 'a', the template for 'a' is redrawn instead of restoring the template. The result is that user data in pattern "a" is lost as soon as I switch from "a".

(the problem exists for the angular built-in routing service).

Now this is the only reason I would not want to have a ui-router (everything else is fantastic), because this behavior does not correspond to one of our most important use cases. Also for me personally this does not seem to be the most logical behavior.

I wanted to know if there is a way to achieve this using the built-in.

(I was able to get this behavior after several hacks in the source code.)

+4
source share
2 answers

If an application keeps track of state by views, there are two ways that I know that you save data when the view changes.

  • One of them is to determine the state of the view in the parent area ng-viewor ui-view. This area can be $rootScopeeither an area that does not change when navigating. For example, if you define something like $rootScope.user={};. Anywhere you enter $ rootScope, you will get this custom object that you can update.

  • -, , . , . , UserCreateWuzard, \property, userToCreate. , . , - .

+1

. , , : :

:

$stateProvider.state('billing', {
    sticky: true,
    views: {
        'billing' : {
            templateUrl: 'billing.html',
            controller: 'BillingController'
        }
    }
});

/,

<main ui-view></main>
<div ui-view="billing" ng-show="$state.current.name==='billing'"></div>
0

All Articles