Angular Cookie read and write operations, the code is as follows: var app = angular.module('Mywind',['ui.router']) app.controller('Myautumn',function($scope,$http,$filter){ //angular Cookie write//Usage: $scioe.addCookie("name", value, time,"/") $scope.addCookie = function(name, value, days, path) { var name = decodeURI(name); var value = decodeURI(value); var expires = new Date(); expires.setTime(expires.getTime() + days * 3600000 * 24); path = path == "" ? "" : ";path=" + path; var _expires = (typeof days) == "string" ? "" : ";expires=" + expires.toUTCString(); document.cookie = name + "=" + value + _expires + path; } //angular Cookie reading //Usage: $scope.getCookieValue("name") $scope.getCookieValue = function(name) { var name = decodeURI(name); var allcookies = document.cookie; name += "="; var pos = allcookies.indexOf(name); if(pos != -1) { var start = pos + name.length; var end = allcookies.indexOf(";", start); if(end == -1) end = allcookies.length; var value = allcookies.substring(start, end); return(value); } else { return ""; } }; }) This is the end of this article about Angular Cookie reading and writing operation code. For more relevant Angular Cookie reading and writing content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Summary of various methods of implementing article dividing line styles with CSS
>>: How to center your HTML button
Table of contents 1. Add attributes 2. Merge mult...
Preface Review and summary of mobile terminal rem...
Table of contents What is Express middleware? Req...
1. Naming conventions 1. Database names, table na...
Why optimize: With the launch of the actual proje...
Copy code The code is as follows: <iframe id=&...
This article shares the specific code of js+Html ...
Table of contents 1. Create a socket 2. Bind sock...
The main differences are as follows: 1. MySQL use...
Perform the following operations in the Ubuntu co...
mysql permissions and indexes The highest user of...
1. Apache server installation and configuration y...
2.1 Semanticization makes your web pages better u...
<br />I have always believed that Yahoo'...
Related system calls for file operations create i...