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
When I first came into contact with docker, I was...
This article example shares the specific code of ...
Table of contents 1. Registering custom instructi...
Preface Samba is a free software that implements ...
I found an example when I was looking for a way t...
Use the following command to check whether MySQL ...
Preface The company's Ubuntu server places th...
HTML style tag style tag - Use this tag when decl...
This project shares the specific code of Vue+Rout...
When developing a project, you will often encount...
The docker repository itself is very slow, but th...
This article shares the specific code for WeChat ...
This article shares the specific code of JavaScri...
Due to business needs, there are often rush purch...
W3C recently released two standards, namely "...