AngularJS provides good $cookie and $cookieStore APIs to handle cookies.
Both services are able to play HTML5 cookies well, and when the HTML5 API is available the browser chooses to use the API provided by HTML5 and, if not available, chooses document.cookies by default. Either way, you can choose to use phase
The same API to work on.
You can now manipulate cookies using the put, get, and remove methods, $cookieStore can store objects directly into cookies, which are automatically serialized and deserialized using Angularjs Tojson/fromjson
$cookieStore. Put ("name", "My Name");
$cookieStore. Get ("name") = = "My Name";
$cookieStore. Remove ("name");
$cookieStore. Put ("Persion", {
Name: "My Name",
Age:18
});
$scope. person = $cookieStore. Get ("persion");
Using cookies
$cookies. Put (' SESSIONSZWC ', sessionobject);
$cookies. Get ("SESSIONSZWC");
$cookies. Remove (' SESSIONSZWC ');
$cookies. myfavorite = ' oatmeal haha ';
Scope is a bridge between HTML and a single controller, and data binding depends on him.
Rootscope is the bridge of scope in each controller. Values defined with Rootscope can be used in each controller
Angularjs Summary (eight) $ cookie and $rootscope