私は、フィーチャーアイテムの変数を「入力」から「検索」に変更するまで、フィーチャーアイテムのアイテム数を取得できなかったのはなぜですか?以下は私の特色-item.component.htmlです:コンポーネントを共有するときに入力名が異なる必要があるのはなぜですか?
以下<rb-featured-item [search]="searchFeaturedItem" [isWhole]="isWhole"
[minMax]="isFeaturedMin">
</rb-featured-item>
<rb-product-list [searchType]="searchType" [subType]="subType"
[input]="searchStr" >
</rb-product-list>
は私の特色-item.component.tsです:
以下searchStr: string;
searchType: string;
subType: string;
searchFeaturedItem: string = 'cell phones'; // show all featured items in cell phones..
isFeaturedMin: boolean = true;
isWhole: boolean = true;
ngOnInit() {
this.searchStr = 'cell phones'; // product-list searches for all cell phones in su-category..
this.searchType = 'sub-category';
this.subType = 'none';
window.scrollTo(0, 0);
}
は私の特色-items.component(共有コンポーネント)です。これは私が「検索」から「入力」に変更するまで、私のコードが項目の数を取得できない場所です。製品リストには、
<rb-product-list [input]> //and
<rb-featured-item [input]>
が表示されています。なぜエラーが発生しますか?私の発見を分かち合っているので、私の質問に投票しないでください。
//selector: 'rb-featured-item' -- see top
export class FeaturedItemComponent implements OnInit, OnChanges {
@Input ('search') searchStr: string; // ** errors if 'input' instead of 'search'***
@Input('width') mainWidth: number;
@Input ('leftMargin') mainLeftMargin: string;
@Input('isWhole') isWhole: boolean;
@Input('minMax') isMin: boolean;
featuredItems: FeaturedItem[] = [];
isFeatured: boolean;
私もために奇妙な行動に遭遇しました問題を引き起こす文書化されていない入力名。既存のHTML属性名の使用に問題があったのか、Typescriptで注釈がどのように機能するのかが問題であったのかどうかは分かりません。予約語を入力名などに使用することはできません。もしAngularがこれらの素晴らしいリストをdocで避けていればうれしいでしょう。 – cgTag