0

I am working in angularjs and i am facing the issue onreload of the page. When i refresh the page the object value is set as null due to which conditions are failing in the controller.

 var limitOrderReqBean = null;
 obj.updateLimitOrderReq = function(limitReqBean) {
     limitOrderReqBean = limitReqBean;
 }
 obj.getLimitOrderReqBean = function() {
     return limitOrderReqBean;
 }

This is the code which is used in cartservice.js, where limitOrderReqBean this is the object used in controller. Initialized var limitOrderReqBean = {}; but still onrefresh it sets as empty object.

Sudhir Ojha
  • 3,247
  • 3
  • 14
  • 24
raksha dk
  • 11
  • 2
  • I don't get your question. The first line sets `limitOrderReqBean` to null. What is it supposed to do? – Ruben Helsloot Jul 17 '20 at 08:56
  • Initialized the variable – raksha dk Jul 17 '20 at 09:26
  • What should be its value? – Ruben Helsloot Jul 17 '20 at 09:28
  • it is an object so either i have initialize as null / empty object. – raksha dk Jul 17 '20 at 10:11
  • I don't understand your question. If you change the first line to `var limitOrderReqBean = {}`, it's initialized to an empty object, right? I don't see what you want, or what you think should happen – Ruben Helsloot Jul 17 '20 at 10:18
  • issue is when i refresh that time limitOrderReqBean object will have null ..if i wont refresh the page limitOrderReqBean has value in it. If it takes the null value the object which is used in the controller.js will throw error of null in console. – raksha dk Jul 17 '20 at 12:15
  • So the problem is that when you refresh, the you lose everything. Have a look [here](https://stackoverflow.com/q/28955560/5015356) and [here](https://stackoverflow.com/q/36204281/5015356) – Ruben Helsloot Jul 17 '20 at 12:20

0 Answers0