0
app.factory('theService', function(){
var member = {
myValue: false,
};
return myValue;
});
我上面的代碼,我想改變它來存儲並給從DOM類似下面的Angular.js:工廠在頁面刷新之間存儲值在DOM中?
app.factory('theService', function(){
var member = {
myValue: $window.sessionStorage["myValue"],
};
return myValue;
});
有效地使布爾myvalue的頁面刷新之間持久的存儲。任何其他的想法如何在Angular中解決這個問題?我在auth服務中使用它。
或者更好,使用[現有的模塊(http://stackoverflow.com/q/19304435/2057033)! – Blackhole 2014-09-26 10:59:52
或使用[angular-cache](http://angular-data.pseudobry.com/documentation/guide/angular-cache/configure):> – naeramarth7 2014-09-26 11:02:03
如何在不同的控制器之間執行此操作?例如http://stackoverflow.com/questions/26097671/access-angular-module-via-service-in-rootscope – nottinhill 2014-09-29 12:19:32