TypeScript Error While Using @Input()

Discussão em 'Angular' iniciado por Moaz Sarwar, Setembro 15, 2024.

  1. Moaz Sarwar

    Moaz Sarwar Guest

    I am trying to develop an app using Angular 4. But I have received an error message while using

    @Input('inputProducts') products: Product[];


    The Error is


    [tslint] In the class "ProductListComponent", the directive input property "products" should not be renamed.Please, consider the following use "@Input() products: string" (no-input-rename).
    ​

    The Error Does Not Have any Effect and My App is working fine but it is annoying and am unable to remove it. Code Snippet is Given Below:

    import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
    import { Product } from '../product-row/product.model';
    @Component({
    selector: 'app-product-list',
    templateUrl: './product-list.component.html',
    styleUrls: ['./product-list.component.css']
    })
    export class ProductListComponent implements OnInit {
    @Input('inputProducts') products: Product[];
    @Output() selectedProduct: EventEmitter<Product>;
    constructor() {
    this.selectedProduct = new EventEmitter();
    }
    clickedProduct(p: Product): boolean {
    this.selectedProduct.emit(p);
    return false;
    }
    ngOnInit() {
    }
    }


    the html part

    <app-product-list [inputProducts]="products"></app-product-list>


    Please Point me towards right direction to remove this error.

    Continue reading...

Compartilhe esta Página