I'm trying to integrate crypto-js with my angular 2 app.
Global module exports may only appear at top level angular typings.
I have read the below contents link 1
In webpack how do I fix 'import declarations may only appear at top level of a module'?
But i'm not able to implement a solution
below are the steps i followed.
1) Installed crypto-js using type --> npm install --save @types/crypto-js
2) Then in my service added reference. Below is the service file
/// <reference path="../../../typings/index.d.ts" />
import { Injectable } from '@angular/core';
import { LocalStorageService } from 'angular-2-local-storage';
import * as CryptoJS from 'crypto-js';
@Injectable()
export class AppLocalStorageService {
constructor(public localStorageService: LocalStorageService) { }
public setItem(key:any,value:any) {
var enc = CryptoJS.MD5(key);
console.log(enc);
}
public getItem(key:any) {
return key;
}
}
Still getting the error.Anything else i should do?
Thanks