将Automapper导入Angle2 Webpack项目 [英] Importing Automapper into a angular2 webpack project
本文介绍了将Automapper导入Angle2 Webpack项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Angular2 Webpack项目中使用
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() {
}
}
请记住,我已经修改了tsconfig.json
文件以使其正常工作.
Keep in mind I have amended tsconfig.json
file to get that to work.
"moduleResolution": "node",
到
"moduleResolution": "classic",
这篇关于将Automapper导入Angle2 Webpack项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文