尝试使用基本的hello world模板启动角度2。这是我的 boot.js ,稍后将转换为es5:
import {bootstrap, Component, View} from 'angular2/angular2';
@Component({
selector: 'articles'
})
@View({
template: 'Hello from angular'
})
class application{
}
bootstrap(application);
这是我的 index.jade ,它使用所有必需的脚本扩展layout.jade:
extends layout
block content
//CONTENT
.container(style="margin-top:20px")
articles // <--- ---------------angular app
h1
i(class='fa fa-circle-o-notch fa-spin')
//END CONTENT
控制台未显示任何错误,但仍无法正确加载应用。
layout.jade
中包含的脚本script(src='https://jspm.io/system@0.16.js')
script(type="text/javascript", src="/js/angular-build/boot.js")
我的gulp文件中的Traceur转换器:
gulp.task('build', function () {
return gulp.src(angular_dirs.src)
.pipe(traceur({
modules: 'instantiate',
annotations: true
}))
.pipe(gulp.dest(angular_dirs.dest));
});
我正在使用npm安装的最新角度2。我还包括了一些其他devDependencies:
"es6-promise"
"es6-shim"
"reflect-metadata"
"rxjs"
"systemjs"
答案 0 :(得分:1)
在Angular 2的后期版本中,您无法再从'angular2/angular2'
导入内容。你需要从适当的包裹中取出它们。
例如,要导入Component
,您可以执行以下操作:
import {Component} from 'angular2/core';
我在Alpha 53中删除了angular2/angular2
个包,您可以在重大更改部分的Changelog entry中看到。