{{error}} It works perfect on the client side, but i" /> {{error}} It works perfect on the client side, but i" /> {{error}} It works perfect on the client side, but i"/>

TypeError: str.replace is not a function (Angular 2 Universal)

973 Views Asked by At

I am using Angular 2 Universal.

I have this line in the html part:

<span [hidden]="!error">{{error}}</span>

It works perfect on the client side, but is shows this error in the terminal (because of server rendering) when the page loads:

Rendering Document Error: TypeError: str.replace is not a function

1

There are 1 best solutions below

0
Hongbo Miao On BEST ANSWER

One walkaround solution is using *ngIf instead of [hidden]:

<span *ngIf="!!error">{{error}}</span>

This can get rid of

Rendering Document Error: TypeError: str.replace is not a function

when server renders.


BTW, I would be glad to accept another answer if anyone can find a way using [hidden] without error.