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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -