angular.js - How to save the form data filled in by the user when switching views in the jump route? ~
黄舟
黄舟 2017-05-15 17:12:55
0
3
618

The current solution I can think of is to save it on $rootScope, which is obviously not good...

You can save it in the Service, but what is the timing of saving? Monitor the form input and then call the setter method in real time? ~

Is there a more elegant way?~

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
过去多啦不再A梦

If it is a pop-up window, you can share the same controller

If you must jump the route, there are several ways:

The $rootSope you think of is one

Alternatively, to use services, you can use $cacheFactory provided by angular itself. Its API is very simple. You can understand it just by searching. The timing of saving is just the step before you jump.

The other way is to save the parameters to the URL when jumping, and then use $stateParams to get them. It should be spelled correctly

phpcn_u1582

You can write the route jump in js, and then save the information when you click to jump, and then jump after making sure it is correct
$scope.goToIndex2 = function () {

$location.path("/2")

}

PHPzhong

There is no separate save button. During ng-change, a common method is called to save the entire form, for example, in local storage

I think this is the best way

If you save when jumping routes, you need to add this saving method to all route jumps. It will be very troublesome to design more routes

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template