Hi, I need help with my ionic app. I am not an expert on Angular, still learning it, so I want to ask, how would I ‘reset’ data that are stored in controller/service. Let me explain the skeleton of my app:
MainView [mainCtrl] ↴
SelectingPicture [selectService] ↴
ParametersView [paramsCtrl] ↴ //here user specify the parameters, e.g. how to upload a picture, etc.
Upload [uploadService] ↴ //this takes care about whole POST/fileupload
SuccessView [afterCtrl] ↴ //here, the user specify whether he wants to save the response (edited image) and where. The save function calls the saveService
Save [saveService] //this takes care about writing a file to destination
Everything with the processing is okay, but just for the first time. After I save the output file (for the first time), there is a button in the view, that takes me back to the MainView
(I did that by using UIRouter’s ui-sref
, maybe this is why?). And when I want to repeat those steps with different data, I am successfull with getting through selecting and uploading, but when it comes to saving it uses the data that left saved in factory’s fields from previous attempt. I have already turned of caching, so I have no idea why my factory isn’t reloading it’s fields when injected again. (or the factory in angular is made as a singleton?)
Thank you in forward for any ideas on how to solve this. One solution I have though about is to use $ionicView.loaded event and when that is emitted, call some function on service, that would set the defaults.