2017-04-05 1 views
0

jQuery와 마찬가지로 Viewchild에서 장식 한 객체의 DOM을 쿼리 할 수 ​​있습니까?viewchild로 꾸며진 객체에서 jquery와 같은 작업 수행

나는 아래의 내용을 자녀의 DOM과 같이해야합니다. 네, 가능

@ViewChild('someComponent') child: SomeComponent; 

    ngAfterViewInit() { 
    this.child.queryTheDomElementFor('some tag'); 
    this.child.getDomElementThatContains('specific Content'); 
    this.child.setCss(this.child.someNode, 'css rules'); 
    } 

답변

0

,

@ViewChild('someComponent') someComponent: SomeComponent; 

    ngAfterViewInit() { 
    document.querySelectorAll(..); 
    document.getElementById(..); 
    document.getElementByClass(..); 
// also nativeElement property can be used as 
    this.someComponent.nativeElement.children 
    } 

<element #someComponent> </element> 

업데이트 :

당신이

로 viewChild로 선언 한대로 구성 요소 방법을 사용할 수 있습니다
this.someComponent.someMethod() 
+0

SomeComponent 클래스는 없습니다 그 jQuery 메서드. – Lev

+0

jQuery 메서드는 무엇입니까? 어느 구성 요소 – Aravind

+0

SomeComponent 클래스에는 querySelectorAll 등의 메소드가 없습니다. – Lev