导入外部组件到angular2快速启动项目,打字稿及NPM [英] Importing external components into angular2 quickstart project with typescript and npm

查看:245
本文介绍了导入外部组件到angular2快速启动项目,打字稿及NPM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定尝试angular2,并已享受与玩了,而在后的快速启动由angular.io(阿尔法44)提供的打字稿。但是我似乎遇到了阻碍,我有一个很难导入新的模块通过我得到的节点,更具体的NG2自举的提示。我似乎无法获得快速入门项目的所有工作方式togheter,即使我已经systemjs读了起来,并试图自己摆弄左右。我尝试了各种方法,但似乎总是在某处碰了壁。

我进口NG2自举,虽然这样做:

  NPM我NG2,引导--save

然后用在app.ts进口和参考:

  ///<参考路径=../../ node_modules / NG2-引导/ NG2-bootstrap.d.ts/>
从NG2自举进口{}提示

然而,它一直在寻找它不会为角度成分做'src'中的文件夹使用进口的时候,为什么呢?任何人都可以帮助我了解事情是如何togheter联系在一起的,有什么我不理解?

我在浏览器控制台得到的错误是:

 无法加载资源:服务器与404状态响应(未找到)http://127.0.0.1:8080/src/ng2-bootstrap


解决方案

我回来这个问题一段时间后,发现这样的:的https://github.com/valor-software/ng2-bootstrap/issues/50#issuecomment-165448962

以下链接将展示如何在angular2-beta0快速入门导入NG2自举(或其他NPM模块)。

I decided to try out angular2, and have been enjoying playing around with it while expanding upon the quickstart in typescript provided by angular.io (alpha 44). However I seem to have hit a snag, I am having a hard time importing new modules I got through node, more specifically the tooltip in ng2-bootstrap. I just can't seem to "get" how the quickstart project all works togheter, even if I have read up on systemjs, and tried tinkering around myself. I have tried various approach but always seem to hit a wall somewhere.

I imported ng2-bootstrap though by doing:

npm i ng2-bootstrap --save

Followed by using an import and reference in the app.ts:

/// <reference path="../../node_modules/ng2-bootstrap/ng2-bootstrap.d.ts"/>
import {tooltip} from 'ng2-bootstrap'

However it keeps looking in the 'src' folder which it does not do for the angular component when using import, why? Could anyone help me understand how things are linked togheter, and what I am not understanding?

The error I get in the browser console is:

Failed to load resource: the server responded with a status of 404 (Not Found) http://127.0.0.1:8080/src/ng2-bootstrap

解决方案

I came back to this issue after a while, and found this: https://github.com/valor-software/ng2-bootstrap/issues/50#issuecomment-165448962

Following the link will show how to import ng2-bootstrap (or other npm modules) in the angular2-beta0 quickstart.

这篇关于导入外部组件到angular2快速启动项目,打字稿及NPM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆