I have downloaded a sample of an admin dashboard in Typescript/Angular. It's built up in a very modular way with .component, .routing, .module files.
Now I need to import the cookie module. I was used to import modules by injecting them into a Component constructor from what I've read, but the Angular documentation says that I need to use the
angular.module('app', ['ngCookies']);
directive to import it.
So I tried it but it gives me an error (cannot find 'angular'). I think the problem might be that its meant for javascript.
Can anyone help me with a minimal example of importing cookies in typescript?
These comments set me on the right track. If anyone struggles with this,
use
import { CookieService } from 'ng2-cookies';
then in the Component
@Component{(
providers: [ CookieService ]
})
now it works with constructor injection
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.