MdTabGroup uses window which is not defined in node context when doing server side rendering
Bug, feature request, or proposal:
Bug
What is the expected behavior?
MdTabGroup should render without error when doing server side rendering
What is the current behavior?
The following exception occurs:
EXCEPTION: window.requestAnimationFrame is not a function
This is the problematic code:
ngAfterViewChecked(): void {
this._zone.runOutsideAngular(() => {
window.requestAnimationFrame(() => {
this._updateInkBar();
});
});
this._isInitialized = true;
}
What are the steps to reproduce?
Server side rendering of MdTabGroup.
What is the use-case or motivation for changing an existing behavior?
Allow for server side rendering when using MdTabGroup.
Which versions of Angular, Material, OS, browsers are affected?
Angular: 2.0.1 Material: 2.0.0-alpha.8-2
Is there anything else we should know?
Here is the proposed fix:
ngAfterViewChecked(): void {
this._zone.runOutsideAngular(() => {
if ( typeof window.requestAnimationFrame !== 'undefined' ) {
window.requestAnimationFrame(() => {
this._updateInkBar();
});
} else {
this._updateInkBar();
}
});
this._isInitialized = true;
}
This fixed it for me. https://github.com/angular/material2/issues/308#issuecomment-252806444
Thank you! That works.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.