第一次使用 angular2 ,按照 5 minute Quickstart guide 的说明进行操作对于 Angular 2。
一切正常,意味着运行 npm start
时没有错误
但是当我打开
localhost:3000
它显示 Loading... 不期望的文本。根据此示例,index.html 的内容应反射(reflect)这一点。
控制台出现错误:
异常:TypeError:无法将属性“endSourceSpan”设置为 null
主.ts
import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
bootstrap(AppComponent);
应用程序组件.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: 'My first Angular 2 App</h1>'
})
export class AppComponent {}
index.html
<html>
<head>
<title>Angular 2 QuickStart</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>
</html>
请帮我看看哪里出了问题。
最佳答案
我认为您的主要组件的模板有问题。例如,未正确关闭的 HTML 元素:
template : '<div</div>'
有关详细信息,请参阅此问题:
编辑
问题是您的 h1
不正确(没有 begin 元素):
@Component({
selector: 'my-app',
template: '<h1>My first Angular 2 App</h1>' // <------
})
export class AppComponent {}
关于node.js - angular2 quick start 只显示 Loading .. 而不是 index.html 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37277205/