I am attempting to display the difference between two JSON objects in an Angular 4 view. I have been using a library called angular-object-diff, which was originally created for AngularJS.
You can view a demo of this library here: Link
I have tried to import the JS library by referencing this file: angular-object-diff.js, however it does not export a variable.
In my typings.d.ts file, I included the following:
declare var ObjectDiff: any;
In my angular-cli.json configuration, I added the following:
"scripts": [
"../node_modules/angular-object-diff/dist/angular-object-diff.js"
],
In my component file:
const json1 = {
name: 'John'
};
const json2 = {
name: 'Johnny'
};
const diff = ObjectDiff.diffOwnProperties(json1, json2);
this.jsonViewData = ObjectDiff.toJsonDiffView(diff);
In my view:
<pre ng-bind-html="jsonViewData"></pre>
<pre> {{jsonViewData}}</pre>
Despite my efforts, I am encountering an error stating that "ObjectDiff" is not defined in the console.
If anyone could provide insight on where I may be going wrong or offer suggestions for displaying the JSON diff, it would be greatly appreciated :)
** Thank you