【发布时间】:2016-05-26 04:33:00
【问题描述】:
我正在关注来自https://angular.io/docs/js/latest/guide/displaying-data.html 的关于 Angular2 的教程,但它对我不起作用。让我知道我在这里缺少什么。
顺便说一句 - 我只使用 ES5。
index.html 中的代码 -
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Angular2 Demo</title>
<!-- 1. Load libraries -->
<!-- IE required polyfill -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/rxjs/bundles/Rx.umd.js"></script>
<script src="node_modules/angular2/bundles/angular2-all.umd.js"></script>
<script src="app/component.js"></script>
</head>
<body>
<display></display>
</body>
</html>
在component.js -
function DisplayComponent() {
this.myName = "Alice";
}
DisplayComponent.annotations = [
new angular.ComponentAnnotation({
selector: "display"
}),
new angular.ViewAnnotation({
template:
'<p>My name: {{ myName }}</p>'
})
];
如果我在浏览器中运行 idex.html 会出现错误 -
ReferenceError: 角度未定义
【问题讨论】:
标签: javascript html angularjs angular angular2-template