Angular-Cli Best way to manage notices

谁都会走 提交于 2020-01-17 07:53:20

问题


I am migrating an old site to my new Angular CLI project and would like to offer my users a notice.

"This is a new site! To access your old account, go here..."

What I need is a method for the user to close the notice and for it never to return. I am using bootstrap, so the closing part is easy enough... however to persist this I would traditionally use a cookie.

What is the best way to do this in Angular, if cookies are the best way, what component should be used?

Thanks!


回答1:


While cookies are widely used for this purpose, it would not be the right choice. Cookies are meant for data that needs to get to the server with every request.

your best option here is localStorage look at the API here: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

Also look at this quora answer for the difference between sessionStorage, localStorage and cookie. https://www.quora.com/What-is-the-difference-between-sessionstorage-localstorage-and-Cookies

the choice of component is up to you, choose what matches your app.



来源:https://stackoverflow.com/questions/43043205/angular-cli-best-way-to-manage-notices

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!