2016-08-12 2 views

답변

1

이것은 내장 된 tslint 규칙이 아닙니다. codelyzer에 정의 된 규칙입니다.

GitHub 레포에는 비디오 (내가 본 적이없는 비디오)가 있지만 약간의 설명서가 있습니다. 다행히 저자는 테스트를 시행하고, 그래서 그것은 use-life-cycle-interface rule가에서 무엇을 추론하는 것이 가능 그 test descriptions : 단순히 당신이 사용하는 모든 라이프 사이클 훅 implements 키워드를 추가해야 함을 의미

it(`should fail, when a life cycle hook is used without implementing it's interface`, ... 
it(`should fail, when life cycle hooks are used without implementing their interfaces`, ... 
it(`should fail, when some of the life cycle hooks are used without implementing their interfaces`, ... 
+0

또한 절대적으로 내가 JohnPapa에서 집중적으로 WebStorm에 대한 NG2 템플릿을 사용하고이 규칙 후 유효하지 않은 것, 나를 위해 바늘 :) –

1

,

각도가 후크를 인식하고 사용하는 데 반드시 필요한 것은 아니지만 코드 명확성과 유지 관리에 훨씬 좋습니다.

예 :

// don't forget the import 
import { AfterViewInit } from '@angular/core'; 
// you have to have this implements statement 
export class YourComponent implements AfterViewInit { 
    // if you want to use this hook 
    ngAfterViewInit() { 
    // your code... 
    } 
}