Struggling to integrate camanjs with Angular 6? Wondering how to add the JavaScript library and use it within an Angular project when there are no types available on npm? Here are the steps I followed:
First, install Caman using npm.
Next, add it to angular.json as a script by specifying its path in the node modules directory.
Import it into the component like this:
import * as Caman from 'path to Caman in node_modules'
- In ngAfterViewInit, you can use it like this:
ngAfterViewInit() { Caman('#image-id', function () { this.brightness(10); this.contrast(20); }); }
However, upon starting the server, I encountered this error:
https://i.sstatic.net/zzadZ.png
For the code sample and more details, visit this link: https://stackblitz.com/edit/angular-d5g941