javascript - 何时在 Angular 2 中使用 @angular 标签?

标签 javascript google-maps angular angular2-routing

我试图使用下面的代码来引导我的应用程序 boot.ts文件:

import {bootstrap}    from 'angular2/platform/browser'
import {ROUTER_PROVIDERS} from 'angular2/router'

import {AppComponent} from './app.component'

bootstrap(AppComponent,[ROUTER_PROVIDERS]);

效果很好。

现在我想尝试添加导入的 Google map angular2-google-maps包,创建了一个 map.component.ts文件并将其添加到路由器映射(在 app.component.ts 文件中定义)。

对于上述包,import {bootstrap} from '@angular/platform-browser-dynamic'; 用于plunker code (作为起始代码提供)。

现在,如果我添加<map>, map 就会显示我的 index.html 中的选择器页。

我希望它遵循之前定义的路由。

引导也会发生两次(一次针对 AppComponent,一次针对 Map)

如何正确引导 map 组件,以便仅在主应用程序中进行引导?

@angular 之间有什么区别?和angular2包以及何时使用它们?

最佳答案

@Angular 适用于 RC(候选发布)版本,Angular2 适用于 Beta 版本。

例如,在 RC 版本中,angular2/core 变为 @angular/core。您还可以注意到 SystemJS 配置有所不同,因为您没有捆绑的 JS 文件。

现在您需要将 Angular2 模块配置到 SystemJS 配置的映射和包 block 中。请参阅此链接了解更多详细信息:

关于javascript - 何时在 Angular 2 中使用 @angular 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37704027/

相关文章:

android - 一旦我限制了我的 Google API key ,它就不再有效

asp.net - 谷歌地图标记根本不显示

asp.net-core - 如何在 ASP.NET Core 中实现 Angular 4 服务器预渲染

javascript - Telerik Appbuilder CLI 构建回调

javascript - <img src> 超时?

php - 谷歌地图api数据库交互

angular - 将 Angular 项目移动到另一个文件夹给了我错误

angular - 类型错误 : guard is not a function

javascript - JQuery动态加载Javascript文件

javascript - 如何使元素假位置 :fixed so it acts fixed until a certain scroll height, 然后附加?