Search Posts

Category: angular-cookies

Angularjs cookie not working in chrome

I’ve created a very simple angularjs application, trying to use make use of angular cookies, and although it works in Firefox and IE, it doesn’t seem to work in Chrome. Here is my html code: <html ng-app=”myApp”> <head> <meta charset=”utf-8″ /> <script src=””></script> <script src=””></script> <script src=”js/cookieApp.js”></script> </head> <body ng-controller=”mainCtrl”> </body> </html> Here is my angular code: (function () { angular.module(‘myApp’, [‘ngCookies’]) .controller(‘mainCtrl’, [‘$cookies’, function($cookies) { $cookies.put(‘myFavorite’, “cheese”); var favoriteCookie = $cookies.get(‘myFavorite’); console.log(“myFavorite = ” […]

How to send cookies explicitly with GET request using AngularJs 1

I am working with angularjs – 1.6. I need to send one http GET request to server along with a cookie explicitly. I mean, I know once we get authorization done successfully, cookies are being sent with every http request automatically. But in my case, I need to send it explicitly. How can I achieve so. Below is the https code: $cookies.put(‘JSESSIONID’, ‘lu5xxkdqgjk5qpv07ufhvln3’); $http({ url:””, method:”GET”, headers: { ‘Accept’: ‘application/json’, ‘X-Rundeck-Auth-Token’:’lu5xxkdqgjk5qpv07ufhvln3′}, “Access-Control-Allow-Credentials” : true }).then(function(response) […]

Cookies are not being accessible in Angular JS

I am working on login application. For that, I am calling a backend service which is a post call. It returns a cookie. Inside cookie, there is a token. I need that token. I am trying to get that token, but it is coming null when I try to access in using $cookie.get method. Can anyone suggest me what could be the possible reason? Here is the code: $http({ url:””, method:”POST”, data:data, headers: { ‘Content-Type’: […]

Data only displayed after refresh AngularJS

I’m using plain controller to make cart system and $ngcookies. Everything works but the only thing that My Data (.name) only displayed at cart after browser refresh/reload, to be honest main HTML and Cart.html in different controller/view ($ngroute). Is there any mistake i made to fix this? Any help will be appreciated. I want my data displayed (live) on click instead of after Refresh HTML <div ng-controller=”AliceController” class=”talent-container”> <div ng-repeat=”talent in talents”> <button type=”button” href=”#” […]

$cookies.get is not a function – Angular JS

Designed two pages. Cookies is not set and showing error. CDN: <script src = “”></script> <script src=””></script> Main Page – Set Cookies / cookies is not set var app = angular.module(‘myApp’, [‘ngCookies’]); app.controller(‘LoginCtrl’, [‘$cookies’, ‘$scope’, ‘$http’, ‘$window’, ‘$location’, function($cookies,$scope, $http, $window, $location) { $cookies.put(‘username’, ‘name’); } Second Page – Get Cookies var app = angular.module(‘myApp’, [ ‘ngTable’, ‘ngCookies’ , ‘ngResource’]); app.controller(‘AccountMappingCtrl’, [‘$scope’, ‘$http’,’$cookies’, ‘NgTableParams’, function($scope, $http, $filter, $cookies, NgTableParams) { $scope.UsernameCookies = $cookies.get(“username”); } It […]