How to set get and clear cookies in AngularJs?

AngularJS has a module called ngCookies, so before injecting ngCookies angular-cookies.js should be included into the application.

Set Cookies – Put method is used to set cookies in a key-value format.

$cookies.put(“username”, $scope.username);

Get Cookies – Get method is used to get cookies.

$cookies.get(‘username’);

Clear Cookies – Remove method is used to remove cookies.

$cookies.remove(‘username’);

Top 50+ Angular Interview Questions with Answers

Angular is one of the most current web development frameworks around the world.  In almost every interview, you will have… Read More

4 years ago