angular


How to set in Angular 4 cookies, type number values


I'm beginning to develop in angular 4 with typescript. I want to save info in cookies. I'm using "ngx-cookie". Put method, just accept for the value as type string and I want to save a number type var. What the best approach for that?
Explanation found
Javascript - Using cookies to store an integer
Cookies in browsers are strings, that seems the reason
In typescript you can use the 'any' type to store values to get around being specific with strong types.
var myInteger: any;
var myString: any;
myInteger = 1 //valid
myString = "helloWorld" //valid
As ngx-cookie put method takes a string you would need to pass a string. I would call JSON.stringify on your object and pass that to the put request.
saveSearchCritereaCookie = new myCookieObject();
var searchCookie: String = JSON.stringify(saveSearchCritereaCookie);
* #param {string} key Id for the `value`.
* #param {string} value Raw value to be stored.
* #param {CookieOptions} options (Optional) Options object.
*/
put(key, searchCookie, options?): void;
Please see the ngx-cookie documentation page for more examples: NGX-Cookie

Related Links

Angular 2 patchValue inserts only first object of nested array
http post error: Uncaught TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context
How to follow RxJS functionnal programming for Angular 4
FIrebase using ionic 2
Accessing the component's values when using `<ng-content>`
How to structure app with classes for objects retrieved with AngularFire2
Best Practise for Observables used in an Angular 2 Data Service
Access a global variable located in the head of Index file within Angular2 component?
passing multiple params in route angular 4
Angular2 trying to get item in an array before array is populated
Find record through HorizonIO in RethinkDB not returning result
How to display json object parameters in angular 2 template typescript
ZoneAwareError when running agular2 application in safari
I want to bind the legend option with checkbox(show legend or not)
How to get value from asynchronous local storage function and pass it to modal ionic 2
Syntax highlighting in Angular 2

Categories

HOME
recaptcha
umbraco7
authorization
wolfram-mathematica
userform
dropzone.js
aws-codepipeline
outlook-addin
fluent-assertions
pivot-table
fontforge
corba
fix
pixel
google-fusion-tables
konvajs
polymer-1.0
cdb
swtbot
coap
uiinterfaceorientation
hibernate-criteria
spring-4
nexmo
netbanx-api
lift
spring-cloud-sleuth
oclazyload
android-device-monitor
nsfontpanel
canvas-lms
appharbor
matlab-uitable
snobol
nuodb
vorlon
istanbul
scodec
jquery-tags-input
rtai
outlook-2016
countdowntimer
apple-watch-complication
owner
ienumerable
datepart
nsolid
amazon-mobile-analytics
unreal-blueprint
wns
yahoo-messenger
phpinfo
rgraph
togglz
javascript-globalize
velocity.js
mpi4py
xlet
protractor-net
aloha-editor
jison
pysftp
bpopup
apache-roller
wunderlist
lastaccesstime
componentkit
worklight-server
sine-wave
apache-commons-exec
nsurlprotocol
telerik-test-studio
socketrocket
application-integration
complete.ly
worklight-studio
django-1.2
sencha-touch-2.2
problem-steps-recorder
eclipse-wtp
.class-file
slimv
icefaces-1.8
utl-file
dvorak
glossary
function-overloading
spaces
windows-explorer
context-sensitive-help
whiteboard
incremental-linking
resource-cleanup

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile