Importing Automapper into a web storage project angular2

综合技术 2018-02-12 阅读原文

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.
   **/

///   

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",
Hello, buddy!

责编内容by:Hello, buddy!阅读原文】。感谢您的支持!