新的角度2范围的NPM包是否可以与JSPM一起使用?

时间:2016-05-03 20:33:29

标签: angular

想知道有没有人尝试使用新的Angular 2候选版本jspm,特别是新的scoped npm包?

npm install --save @angular/core @angular/compiler @angular/common @angular/platform-browser @angular/platform-browser-dynamic rxjs@5.0.0-beta.6 zone.js@0.6.12

并将其与jspm集成?

问候

肖恩

2 个答案:

答案 0 :(得分:1)

它与JSPM完全相同。我仍然需要使用NPM安装它们,以便我的IDE能够正常工作,但我认为很快就会出现更改,以解决这个问题。

答案 1 :(得分:0)

是的,让一切正常。

需要搜索并替换ng2的所有导入

 find ./ -type f -name "*.ts" -exec sed -i -e 's/angular2\/core/@angular\/core/g' {} \;
    find ./ -type f -name "*.ts" -exec sed -i -e 's/angular2\/compiler/@angular\/compiler/g' {} \;
    find ./ -type f -name "*.ts" -exec sed -i -e 's/angular2\/router/@angular\/router/g' {} \;
    find ./ -type f -name "*.ts" -exec sed -i -e 's/angular2\/common/@angular\/common/g' {} \;
    find ./ -type f -name "*.ts" -exec sed -i -e 's/angular2\/http/@angular\/http/g' {} \;
angular2/core -> @angular/core
angular2/compiler -> @angular/compiler
angular2/common -> @angular/common
angular2/platform/browser -> @angular/platform-browser (applications with precompiled templates) + @angular/platform-browser-dynamic (applications that compile templates on the fly)
angular2/platform/server -> @angular/platform-server
angular2/testing -> @angular/core/testing (it/describe/..) + @angular/compiler/testing (TestComponentBuilder) + @angular/platform-browser/testing
angular2/upgrade -> @angular/upgrade
angular2/http -> @angular/http
angular2/router -> @angular/router-deprecated (snapshot of the component router from beta.17 for backwards compatibility)
new package: @angular/router - component router with several breaking changes

并运行:

npm install --save @angular/core @angular/compiler @angular/common @angular/platform-browser @angular/platform-browser-dynamic rxjs@5.0.0-beta.6 zone.js@0.6.12

您还需要进行这些更改:

RouterLink - > ROUTER_DIRECTIVES RouteConfig - >路线 RouteParams - > RouteSegment

RouteSegment有不同的接口,使用getParam(string)而不是get(string)

import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';

问候

肖恩