私はCLIを使用して角度2のアプリケーションを作成しました。私はそれについて学んでいます。ルートをセットアップしようとしていますが、何らかの理由でリンクがクリックされたときに機能しません。角2のルートが動作しない
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule} from '@angular/router';
import { AppComponent } from './app.component';
import { ProductListComponent } from '../products/product-list.component';
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot([
{ path: 'products', component: ProductListComponent }
])
],
declarations: [
AppComponent, ProductListComponent
],
//providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
そして、この:これはapp.module.tsコードです...
を正しく表示されているが、HTMLコンテンツが同じで、私が表示したい成分の含有量が表示されていません私のproduct-list.component.ts
ファイルのコードです:
import { Component, OnInit } from '@angular/core';
@Component({
template: '<p>Component product list</p>'
})
export class ProductListComponent {
title: 'The Products from Component...';
}
Developers Tools Consoleには間違っているとは確信していません。リンクをクリックするとhttpリクエストがありません。
リンク先
<h1>
{{title}}
</h1>
<p>This is a test</p>
<a [routerLink] ="['/products']"> Values list</a>
メインURLはこの1つである:について話してapp.component.html
であるhttp://localhost:4200
、およびリンクがクリックされたときにproduct-list.component.ts
の内容が表示されていない、それはhttp://localhost:4200/products
に変わりはなく、単にURLがHTMLを変更しません.. 何か案が?私は何が起こっているのか調べる方法はありますか?
ありがとうございましたDeborah、Pluralsightでビデオチュートリアルを見ました。「角度:Getting Started」と素晴らしいです! :) – AlexGH
ありがとう!さらに詳しい情報が必要な場合は、ルーティングに関する記事もあります:https://app.pluralsight.com/library/courses/angular-routing/table-of-contents – DeborahK
ありがとう!私はそれを確かに見るでしょう! :) – AlexGH