angular.js - 怎么做到跳转路由切换 view 的时候保存用户填写的表单数据?~
黄舟
黄舟 2017-05-15 17:12:55
0
3
580

目前想到的办法是存到 $rootScope 上 显然不好……

可以保存到 Service 里吧 但是保存的时机是什么呢 监听表单 input 然后实时的去调用 setter 方法吗?~

有没有更优雅的方法?~

黄舟
黄舟

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

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!