Angular2 equivalent of $document.ready()
Copying the answer from Chris:
Got it working:
import {AfterViewInit} from 'angular2/core';
export class HomeCmp implements AfterViewInit {
ngAfterViewInit() {
//Copy in all the js code from the script.js. Typescript will complain but it works just fine
}
You can fire an event yourself in ngOnInit()
of your Angular root component and then listen for this event outside of Angular.
This is Dart code (I don't know TypeScript) but should't be to hard to translate
@Component(selector: 'app-element')
@View(
templateUrl: 'app_element.html',
)
class AppElement implements OnInit {
ElementRef elementRef;
AppElement(this.elementRef);
void ngOnInit() {
DOM.dispatchEvent(elementRef.nativeElement, new CustomEvent('angular-ready'));
}
}