将非核心npm库导入Angular 2 App [英] Import non-core npm Library into Angular 2 App
问题描述
我是Angular 2的新手,我很难导入Regression npm模块 https: //www.npmjs.com/package/regression
在Angular 2应用程序中使用线性回归函数.我的构建包括Angular 2,Webpack和TypeScript.
到目前为止,我已经npm install regression
并将script标记包含在index.html
Hi I am new to Angular 2 and I am having a hard time importing the Regression npm module https://www.npmjs.com/package/regression
within my Angular 2 application to use the Linear Regression function. My build consists of Angular 2, Webpack, and TypeScript.
So far I have npm install regression
and included the script tag within my index.html
<script src="node_modules/regression/src/regression.js"></script>
我的App.Module中也有回归
I have also Regression within my App.Module
import * as Regression from 'regression;
这是我尝试使用回归函数的方法,但是它表明找不到该函数:
This is how I am trying to use the regression function but it is showing that the function cannot be found:
let actualXY = [];
for (var j = 0; j <= 11; j++) {
let entry = [];
entry[0] = j+1;
entry[1] = m.actuals[j];
actualXY[j] = entry;
}
var result = regression('linear', actualXY);
我是否缺少导入Regression包的任何步骤,或者这根本不可能吗?
Is there any steps I'm missing to import the Regression package or is this simply not possible?
推荐答案
如您的导入所示:import * as Regression from 'regression;
,因此您应该使用Regression
而不是regression
,因此应该使用Regression('linear', actualXY);
.此外,在导入的regression
之后还有quote
缺失. PS :我不知道什么是回归,但是我已经从逻辑的角度回答了.
As your import illustrates : import * as Regression from 'regression;
, thus you should use Regression
not regression
, so it should be Regression('linear', actualXY);
instead. Also, there is a missed quote
after the imported regression
. PS: I do not know what is regression but I've answered from a logical point of view.
这篇关于将非核心npm库导入Angular 2 App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!