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! (源链)。感谢您的支持!

您可能感兴趣的

Using AngularJS components in React Using AngularJS components in React ...
Nrwl Welcomes Torgeir Torgeir Helgevold and Trees I’m really excited to ...
Lazy Loading in Angular v2+ Application performance is an important part of web development. We always want ...
【修真院“善良”系列之十六】代码结构中Dao,Service,Controller,Util,Mod... 适合受众 :2年以下的初级程序员和0基础的门外汉 内容大纲: 1.为什么需要一个好的代码结构 2.什么样才是一个好的结构 3....
Building websites for high traffic with REST APIs,... Expose your business logic with REST services Use a javascript framewor...