简体   繁体   English

Angular2-导入多个模块

[英]Angular2 - Import multiple modules

I have done the Tutorial-Guide on www.angular.io and now I'm trying to implement my own Angular2-Component. 我已经在www.angular.io上完成了Tutorial-Guide,现在我正在尝试实现自己的Angular2-Component。

My Typescript looks like this: 我的打字稿看起来像这样:

import {bootstrap, Component, FORM_DIRECTIVES, CORE_DIRECTIVES} from 'angular2/angular2'
import {Http, HTTP_PROVIDERS} from 'angular2/http'
@Component({
    selector: 'Abrechnung',
    template: `
        <br>
        <br>
        <br>
        <h1>{{title}}</h1>
        <li *ng-for="#posten of postenliste">
            {{posten.text}}
        </li>
    `,
    viewProviders: [HTTP_PROVIDERS],
    directives: [FORM_DIRECTIVES, CORE_DIRECTIVES],
})

While the first import loads correctly, the browser looks for the http-module in the wrong folder. 首次导入正确加载后,浏览器会在错误的文件夹中查找http-module。 I also can't see where the first module is coming from. 我也看不到第一个模块的来源。 In my networktrace there is no 'angular2/angular2' call. 在我的网络跟踪中,没有“ angular2 / angular2”调用。 Are these modules included inside the angular2 - library? 这些模块是否包含在angular2-库中?

I am using Visual Studio for development. 我正在使用Visual Studio进行开发。 I think everything is set up the same as in the tutorial. 我认为所有设置都与本教程中的相同。

Where can I find additional information about the "import ... from" stuff in Typescript? 在哪里可以找到有关Typescript中“ import ... from”内容的其他信息? I am not sure which syntax-versions I am using here :-/ 我不确定我在这里使用哪个语法版本:-/

Thx! 谢谢!

Yes, I had to reference the http.dev.js. 是的,我必须引用http.dev.js。 I was missing that one. 我想念那个。

Thought the system.js is doing the magic here. 以为system.js在这里发挥了魔力。

Thx to Eric! 谢谢埃里克!

'angular2/angular2' is a prepacked module bundle on the system.js module loader. “ angular2 / angular2”是system.js模块加载器上的预包装模块捆绑包。 It is not a path. 这不是一条路。 But of course you can load own modules given a path like './your_directory/your_filename' 但是当然,您可以加载给定的路径(例如“ ./your_directory/your_filename”)的模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM