用于ng2+操作cookie, 相当于Angular 1.x $ cookies服务的实现, angular2-cookie的后继者
下载
1 | npm install ngx-cookie --save |
引入
1 | import { CookieModule } from 'ngx-cookie'; |
方法
get()
返回对应key的value
1 | /** |
getObject()
返回对应key的反序列化后的value
1 | /** |
getAll()
返回cookie的所有键值对
1 | /** |
put()
保存给定key的value
1 | /** |
putObject()
序列化后保存key的value
1 | /** |
remove()
删除key对应的键值对
1 | /** |
removeAll()
删除所有cookies
1 | removeAll(): void; |