angular2快速入门仅显示正在加载..而不是index.html的内容 [英] angular2 quick start only showing Loading .. not the content of index.html
问题描述
根据 5分钟快速入门指南中的说明,首次使用angular2 a>表示角度2.
for the first time using angular2 , following the instruction from 5 minute Quickstart guide for angular 2.
一切正常,表示运行npm start
但是当我打开
localhost:3000
localhost:3000
它显示 正在加载... 文本,这不是您所期望的.根据此示例,index.html的内容应对此进行反映.
it show Loading... text which is not expecting. according to this example content of index.html should reflects on this.
控制台中存在错误:
例外:TypeError:无法将属性'endSourceSpan'设置为null
import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
bootstrap(AppComponent);
app.component.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>
请帮助我哪里出了问题.
Kindly help me what is going wrong.
推荐答案
我认为您的主要组件模板有问题.例如,未正确关闭的HTML元素:
I think that you have a problem in the template of your main component. For example a HTML element that isn't correctly closed:
template : '<div</div>'
有关更多详细信息,请参见此问题:
See this issue for more details:
修改
问题是您的h1
不正确(没有begin元素):
The problem is that your h1
isn't correct (no begin element):
@Component({
selector: 'my-app',
template: '<h1>My first Angular 2 App</h1>' // <------
})
export class AppComponent {}
这篇关于angular2快速入门仅显示正在加载..而不是index.html的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!