私はAngular2
プロジェクトを持っています。これは別の人が開発したプロジェクトです。実行する必要があります。私がしたら、npm start
を使用してサーバーを稼働させましたが、my-app
というコンポーネントがページに表示されません。コンポーネントがページに表示されない
これはindex.html
です:
<html>
<head>
<base href='/'>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="c3.css" rel="stylesheet" type="text/css">
</head>
<body>
<my-app>Loading......</my-app>
</body>
</html>
これはapp.components.ts
です:
app/app.component.html
ある
my-app
ため
template
、で
import { Component } from '@angular/core';
import { AuthenticationService } from './authentication.service';
import { Router } from '@angular/router';
@Component({
selector: 'my-app',
templateUrl: 'app/app.component.html',
styleUrls: ['app/app.component.css']
})
export class AppComponent {
title = '';
isProd:boolean;
constructor(private authenticationService: AuthenticationService, private router: Router) {
this.isProd = false;
}
私はテストのための簡単なdiv
を置く:
<div><h1>app components</h1></div>
これを実行するとindex.html
にあるLoading.....
が表示されますが、app/app.component.html
の内容は表示されません。
私には何が欠けていますか?
コンソールでエラーがないか確認してください。 –
私はc3.cssが見つかりません。 – Eddy
AuthenticationServiceとは何ですか?私は数日前に同じ問題を抱えていました。プロバイダを@Componetに追加する必要がありました(たとえば、「providers:[AuthenticationService]」) –