Use AngularJs language in ASP. net mvc (7): use of cookies, mvcangularjs
For website development, you can use cookies to read and write temporary data. You can use C #, javascript, jQuery, angularjs, and so on to read and write data ......
This article implements operations such as reading, writing, and moving cookies in angularjs environment.
First, compile the angularjs controller:
PilotApp. controller ('cookiectrl', function ($ scope, $ window, $ cookieStore) {$ scope. write_Cookie = function () {$ cookieStore. put ("CookieValue", $ scope. cookieValue) ;}; $ scope. read_Cookie = function () {$ window. alert ($ cookieStore. get ('cookievalue ') ;}; $ scope. remove_Cookie = function () {$ cookieStore. remove ('cookievalue ') ;};}); Source Code
Modify angularjs app code:
Create an Action for ASP. net mvc and add it to the previously created controller:
In the ASP. net mvc project, add the View:
Demo: