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!阅读原文】。感谢您的支持!

您可能感兴趣的

A Closer Look at the Drag and Drop Feature for Ang... In this post, we are going to take a close look at the drag and drop feature coming to Angular 7 Content Development ...
The Future of JavaScript Frameworks Looks Very Fas... One of the reasons I love writing about JavaScript frameworks is that they are incredibly impressive pieces of engineeri...
Angular2 beta 11 Unable to read property field of ... I am trying to setup browser-sync on my gulp pipeline for development but I can't seem to get the reload working. A brow...
Django for React/Angular/Mobile Apps — Part 1 Django for React/Angular/Mobile Apps — Part 1 Designed by Freepik This article...
Angular 开发学习 04 – 组件和模块 获取本章的源代码,可以使用 git clone https://gitee.com/devbean/learning-angular-todomvc.git ,然后检出 cp04 标签: git checkout cp04 即可。 ...