私のアプリケーションで星ランク付けのネストされたコンポーネントを使用していますが、追加するとアプリケーションでは機能しません。私は私のテンプレートで私の新しいコンポーネントのセレクタを使用し、app.module宣言でコンポーネントとして宣言しました。角度2のネストされたコンポーネントを使用すると、アプリケーションが動作しない
star.component.html
<div class="crop"
[style.width.px]="starWidth"
[title]="rating">
<div style="width: 86px">
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
<span class="glyphicon glyphicon-star"></span>
</div>
</div>
star.component.ts
import { Component, OnChanges } from '@angular/core';
@Component({
selector: 'ai-star',
templateUrl: 'app/shared/star.component.html',
styleUrls: ['app/shared/star.component.css']
})
export class StarComponent implements OnChanges {
rating: number=4;
starWidth: number;
ngOnChanges(): void {
this.starWidth = this.rating * 86/5;
}
}
app.module.ts私はすべてのために一つだけのモジュール(ルート)を使用
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { ProductListComponent } from './products/product-list.Component';
import { ProductFilterPipe } from './products/product-filter.pipe';
import { StarComponent } from './shared/star.component';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule,FormsModule ],
declarations: [ AppComponent,ProductListComponent,ProductFilterPipe,StarComponent],
bootstrap: [ AppComponent ]
})
export class AppModule { }
私のコンポーネント。私が何かを見逃しているなら、これを解決するのを手伝ってください。
ようにする必要があり、あなたはすべてのエラーを得ていますか?可能であれば同じplankerを提供してください – ranakrunal9
plzあなたのrouting.tsファイルを表示してください。私はあなたがそこで間違いをしていると思います。 –