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

您可能感兴趣的

Multiple packages repository with Angular Managing modules across different applications can be challenging for Angular applications. There are different approaches that you can take that wil...
Introduction to Angular 2 – Part 3 In this article we’ll learn how to use the successors of former Angular 1.x filters: Pipes . As most of us know from own experience the data our a...
Angular Module Tutorial: Application Structure Usi... In my previous post we generated a project using theAngular CLI. In this post I am going to discuss the structure of an Angular application. Specific...
Onsenui; [Ng: areq&a... I am developing a hybrid app using Onsenui and cordova.i got this error in while loading in controller ons-page . I have referred many stackoverfl...
File Upload Using Angular4/Microservice Uploading a file is a regular feature of web programming. Every business needs this ability, and we know how to upload a file using JSP/HTML as a fron...