javascript - How to extend cookie -
this setting once user login application
$rootscope.user = { username: data.username, role: data.role, ticket: data.ticket}; $cookiestore.put( 'appcookie', $rootscope.user );
after api invoking user details , have add firstname , lastname cookie
something
$rootscope.user = { username: data.username, role: data.role, ticket: data.ticket,firstname:data.firstname,lastname:data.lastname}; $cookiestore.put( 'appcookie', $rootscope.user );
but dont want repeat code again
is there way extend cookie mean add firstname , lastname existing cookie
i using angular js $cookiestore
$rootscope.user = { username: data.username, role: data.role, ticket: data.ticket}; $cookiestore.put( 'appcookie', $rootscope.user );
we can use angular.extend achieve this.
angular.extend({firstname:data.firstname,lastname:data.lastname}, $rootscope.user); console.log($rootscope.user);
Comments
Post a Comment