Reputation:
I'm trying to create a application with angular 2,i have an <a>
tag and using ("click") event
.I want when an component rendering finished my a tag trigger click using jquery.But not working !
here is my .HTML code :
<a href="" id="all_m" ('click')="test($event)"></a>
in my another component : export class inside_group_page implements OnInit{
ngOnInit(){
jQuery("#all_m").trigger("click");
}
Upvotes: 1
Views: 2726
Reputation: 1169
do not use jquery with ng2
@Component({
selector: 'inside-page-group',
template: `<a #all_m href="" ('click')="test($event)"></a>`
}
export class InsideGroupPage {
@ViewChild('all_m')
private allMElementRef;
constructor(@Inject(Renderer) private renderer: Renderer){
}
ngAfterViewInit() {
this.renderer.invokeElementMethod(this.allMElementRef.nativeElement, 'click', []);
}
}
Upvotes: 2