navigationController.$inject = [ '$scope', '$cookies' ];
function navigationController($scope, $state, $http, navbarservice,
$cookies) {
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId());
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail());
console.log('id_token: ' + googleUser.getAuthResponse().id_token);
$cookies.put("useEmail", profile.getEmail());
$cookies.put('IdToken', googleUser.getAuthResponse().id_token);
$cookies.put('userName', 'Shreyas');
console.log($cookies.get(IdToken));
}
window.onSignIn = onSignIn;
我试图在cookie中存储值,但不知道为什么我收到此错误,并且我包含了cookies.min.js文件并添加了依赖项' ngCookies'还
答案 0 :(得分:0)
TypeError意味着$cookies
的值未定义 - 请确保正确注入此服务。
答案 1 :(得分:0)
如果您使用的是1.3.x版或更低版本,则可以按如下方式使用$ cookies
$cookies.key = "data";
var value = $cookies.key;
其他您需要使用$cookieStore
$cookieStore.put("key", "value");
var value = $cookieStore.get("key");
参考:click here