Skip to content

Latest commit

 

History

History
228 lines (153 loc) · 2.77 KB

no-interpolation-in-attributes.md

File metadata and controls

228 lines (153 loc) · 2.77 KB

@angular-eslint/template/no-interpolation-in-attributes

Ensures that property-binding is used instead of interpolation in attributes.

  • Type: suggestion

Rule Options

The rule does not have any configuration options.


Usage Examples

The following examples are generated automatically from the actual unit tests within the plugin, so you can be assured that their behavior is accurate based on the current commit.


❌ - Toggle examples of incorrect code for this rule

Default Config

{
  "rules": {
    "@angular-eslint/template/no-interpolation-in-attributes": [
      "error"
    ]
  }
}

❌ Invalid Code

<input type="text" name="{{ foo }}">
                         ~~~~~~~~~



Default Config

{
  "rules": {
    "@angular-eslint/template/no-interpolation-in-attributes": [
      "error"
    ]
  }
}

❌ Invalid Code

<input type="text" name="{{ foo }}bar">
                         ~~~~~~~~~~~~



✅ - Toggle examples of correct code for this rule

Default Config

{
  "rules": {
    "@angular-eslint/template/no-interpolation-in-attributes": [
      "error"
    ]
  }
}

✅ Valid Code

<input type="text" [name]="foo">



Default Config

{
  "rules": {
    "@angular-eslint/template/no-interpolation-in-attributes": [
      "error"
    ]
  }
}

✅ Valid Code

<input type="text" name="foo" [(ngModel)]="foo">



Default Config

{
  "rules": {
    "@angular-eslint/template/no-interpolation-in-attributes": [
      "error"
    ]
  }
}

✅ Valid Code

<input type="text" [name]="foo + 'bar'">



Default Config

{
  "rules": {
    "@angular-eslint/template/no-interpolation-in-attributes": [
      "error"
    ]
  }
}

✅ Valid Code

<input type="text" [name]="foo | bar">



Default Config

{
  "rules": {
    "@angular-eslint/template/no-interpolation-in-attributes": [
      "error"
    ]
  }
}

✅ Valid Code

<div>{{ content }}</div>