S
S
Svyatoslav Khusamov2017-02-10 16:46:53
Angular
Svyatoslav Khusamov, 2017-02-10 16:46:53

How to properly render MaterialDesign components under universal.angular?

I installed https://universal.angular.io/
using the CLI https://www.npmjs.com/package/universal-cli
Everything works. Fine. Implemented the Tour of Heroes example from the manual https://angular.io/docs/ts/latest/tutorial/toh-pt1.html
It also works.
Next, I installed https://material.angular.io/
And slightly tweaked the Tour of Heroes by introducing
https://material.angular.io/components/component/input
There, of course, the client part worked. But rendering on the server does not work. For example, there is no access to the DOM element's hasAttribute method. Because there is no emulation of this method in Universal. And possibly everyone.
A solution was proposed to replace the component on the server with its own stub, which is free from accessing the browser functionality.
But this solution is inconvenient because you have to write a lot of stubs.
I found a solution by including schemas: [ CUSTOM_ELEMENTS_SCHEMA ] in @NgModule. Rendering is in progress. Only problematic components are not rendered. Already better. At least something is rendered, at least something will be indexed. And client rendering does not break.
Is there a normal solution to this problem? To make the rendering complete?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question