Angular 2 cli 设置问题
Angular 2 Setup Issue with cli
首先,我是 Angular 2 的新手,我使用 Angular cli 工具创建了新项目。
我已将我的代码推送到此处(而不是将所有文件粘贴到此处):
https://github.com/tsingh38/Angular2
当我 运行 ng serve then serve starts successfully but browser shows just "Loading".
根据我目前的研究,package.json 和其他文件完全没问题。
如果需要更多信息,我会回答。
谢谢。
转到您的 src/index.html
文件并更改此内容:
<app-root>Loading...</app-root>
为此:
<my-app>Loading...</my-app>
为什么?因为在您的 src/app/app.component.ts
上,您的选择器是 my-app
:
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app works!';
}
首先,我是 Angular 2 的新手,我使用 Angular cli 工具创建了新项目。
我已将我的代码推送到此处(而不是将所有文件粘贴到此处):
https://github.com/tsingh38/Angular2
当我 运行 ng serve then serve starts successfully but browser shows just "Loading".
根据我目前的研究,package.json 和其他文件完全没问题。 如果需要更多信息,我会回答。
谢谢。
转到您的 src/index.html
文件并更改此内容:
<app-root>Loading...</app-root>
为此:
<my-app>Loading...</my-app>
为什么?因为在您的 src/app/app.component.ts
上,您的选择器是 my-app
:
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app works!';
}