请教。我在pc站里用angular,是个课程主页,点击收藏是用的angular,问题是:点击收藏后,再点进入课程跳转到别的页面,然后再点击浏览器的回退,退到课程主页后,发现收藏状态不是刚刚操作后的结果,好像是js里的变量缓存了。请问这个怎么解决呢?
为情所困2017-05-15 17:03:29
This problem should not occur. According to my idea, the collection status of your page should be controlled by a certain data passed to you by the backend. After you click Collection, send a request to the backend, and then the backend Update that data and return that data to you. As long as this data is updated, won't your collection status be updated? No matter how you enter the page, the collection status should be some data returned to you by the backend, and it will not follow the progress of your browser. There has been a change in going back. I don’t know if my explanation is the same as what you asked
天蓬老师2017-05-15 17:03:29
First of all, your collection interacts with the server. Secondly, when your page jumps, the controller of the previous page has been destroyed, and there is no variable cache. I think it is necessary for you to retrieve the collected data when the controller is initialized and then display it on the page
大家讲道理2017-05-15 17:03:29
As long as the URL is changed, the current Controller will be destroyed. When you jump to the interface again by changing the URL, the data in the scope will be initialized data, unless the background sets a value for the object