[英]Is it possible to store session in simple JavaScript function and then access that session attribute in angularjs?
我正在嘗試將選定的單選按鈕的值存儲在JavaScript的會話存儲中。后來我希望將該值用於angularjs函數。是否可以。如果是,請幫助我
是的,您可以使用瀏覽器的localStorage
window.localStorage - stores data with no expiration date
code.sessionStorage - stores data for one session (data is lost when the tab is closed)
// Store
localStorage.setItem("lastname", "Smith");
// Retrieve
document.getElementById("result").innerHTML = localStorage.getItem("lastname");
在AngularJS中,您可以使用Angular-local-storage
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.