javascript - How can I keep my input data when moving to other routes on AngularJS? -
i have angularjs application dynamically created.
because of that, may have normal <form> submit button, inside of there link one, , 1 , on.
i've accomplished correctly submit data no matter how deep in "form-net" user is, problem user might not fill them in "correct order", , user freely so.
for example, he/she start filling form a , realizing there form b inside of it, move route, filling , submitting form b , when coming , form a empty.
so, want pre-save input data user filled. want sort of cache of input user might give, user can move freely 1 form without obligation submit.
you try using angular service , inject dependency in controllers forms use. bind data service rather controller. since service singleton, created once , not recreated user moves throughout app. data bound values persist long don't change them , user stays in app.
the service this:
app.service('myservice', function () { return { form1data: {}, form2data: {}, form3data: {} }; }); and bind correct formndata field in view layer. if number of forms ends being dynamic, can add configuration block angular app indicates how many of these form data object you'll need , use inside service function.
Comments
Post a Comment