8

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.

2
  • what is the HTML looks like please update fully Commented Nov 4, 2017 at 6:18
  • Did you read the error message before posting? It tells you what to do to get rid of the error ;) Commented Nov 4, 2017 at 7:29

5 Answers 5

8

@Input() inputProducts: Product[]; should fix your problem.

Sign up to request clarification or add additional context in comments.

1 Comment

That is actually not what I want to achieve.
7

It's styleguide, no-input-rename the rule that you should set to false not to get such tslint error. no-input-rename is set to true usually when you generate your project with Angular CLI. Go to your tslint file and make it's value equal to false. Should look something like: "no-input-rename": false.

Comments

1
products: Product[];

@Input('inputProducts')
set productsFromInput(projects: Project[]) {
  this.products = products;
}

Comments

1

in .eslintrc.json file under the rules section add these line

"@angular-eslint/no-input-rename": "off"

//Like That

"overrides": [
{
  "rules" : {
    "@angular-eslint/no-input-rename": "off"
  }
}

]

Comments

0
  @Input() product!: Product;

should fix it

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.