I am trying to implement crypto-js with Ionic 2.
I have done the following:
npm install crypto-js typings install dt~crypto-js --global --save
My index.d.ts
now contains:
/// <reference path="globals/crypto-js/index.d.ts" />
A crypto-js
folder has been created under ./typings/global
I then try the following code:
declare var require: any;
import * as CryptoJS from 'crypto-js';
...
private CryptoJS: any;
constructor() {
this.CryptoJS = require("crypto-js");
}
test() {
alert(this.CryptoJS);
}
As soon as I try reference this.CryptoJS
(i.e alert(this.CryptoJS)
) the app crashes.
I am doing something wrong in the way I import the crypto-js
libraries. Please can anyone advise?
Thanks