I am trying to use the ts automapper libary in an Angular2 webpack project but not sure how to import it or include it. An example how to accomplish this would be great.
There maybe be better way to work with this library, however, what I have done in my project is this
/** test.component.ts
** Please note that you need to change Path as this is referenced to my node_module and probably it's different in your end.
**/
/// <reference path="../../../../node_modules/automapper-ts/dist/automapper.d.ts" />
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'test-component',
})
export class TestComponent implements OnInit {
private jsonObj;
constructor() {
automapper.map("JSON", "newType", this.jsonObj);
}
ngOnInit() {
}
}
Keep in mind I have amended tsconfig.json file to get that to work.
"moduleResolution": "node",
to
"moduleResolution": "classic",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With