확장 진단

문자열 바인딩에서는 함수를 호출해야 합니다

이 진단은 문자열 바인딩에서 호출하지 않은 함수를 감지합니다.

import {Component} from '@angular/core';

@Component({
  template: `{{ getValue }}`,
})
class MyComponent {
  getValue() {
    return 'value';
  }
}

무엇이 문제인가요?

문자열 바인딩의 함수는 값을 반환하도록 호출해야 합니다. 함수를 호출하지 않으면 값이 반환되지 않아 문자열 바인딩이 예상대로 동작하지 않습니다.

어떻게 해결하나요?

문자열 바인딩에서 함수를 사용할 때는 값을 반환하도록 함수를 호출하세요.

import {Component} from '@angular/core';

@Component({
  template: `{{ getValue() }}`,
})
class MyComponent {
  getValue() {
    return 'value';
  }
}

필수 설정

확장 진단이 발생하려면 strictTemplates를 활성화해야 합니다. uninvokedFunctionInTextInterpolation에는 strictTemplates 외의 추가 요구 사항이 없습니다.

이 상황을 피할 수 없다면 어떻게 하나요?

프로젝트의 tsconfig.json 파일을 수정하여 이 진단을 비활성화할 수 있습니다.

{
  "angularCompilerOptions": {
    "extendedDiagnostics": {
      "checks": {
        "uninvokedFunctionInTextInterpolation": "suppress"
      }
    }
  }
}

자세한 내용은 확장 진단 설정을 참고하세요.