Skip to content

Commit 3848e43

Browse files
authored
docs(readme): renderer2 fix
1 parent 8a02df7 commit 3848e43

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ Well now, your Client-side Angular will take over, and you'll have a fully funct
337337
- **`window`**, **`document`**, **`navigator`**, and other browser types - _do not exist on the server_ - so using them, or any library that uses them (jQuery for example) will not work. You do have some options, if you truly need some of this functionality:
338338
- If you need to use them, consider limiting them to only your client and wrapping them situationally. You can use the Object injected using the PLATFORM_ID token to check whether the current platform is browser or server.
339339

340-
```
340+
```typescript
341341
import { PLATFORM_ID } from '@angular/core';
342342
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
343343
@@ -358,9 +358,9 @@ Well now, your Client-side Angular will take over, and you'll have a fully funct
358358
- Try to *limit or* **avoid** using **`setTimeout`**. It will slow down the server-side rendering process. Make sure to remove them [`ngOnDestroy`](https://angular.io/docs/ts/latest/api/core/index/OnDestroy-class.html) in Components.
359359
- Also for RxJs timeouts, make sure to _cancel_ their stream on success, for they can slow down rendering as well.
360360
- **Don't manipulate the nativeElement directly**. Use the _Renderer2_. We do this to ensure that in any environment we're able to change our view.
361-
```
362-
constructor(element: ElementRef, renderer: Renderer) {
363-
renderer.setElementStyle(element.nativeElement, 'font-size', 'x-large');
361+
```typescript
362+
constructor(element: ElementRef, renderer: Renderer2) {
363+
this.renderer.setStyle(element.nativeElement, 'font-size', 'x-large');
364364
}
365365
```
366366
- The application runs XHR requests on the server & once again on the Client-side (when the application bootstraps)

0 commit comments

Comments
 (0)