Skip to content

Commit 19eaa55

Browse files
committed
docs NgZone in Tabs
1 parent 8967b0b commit 19eaa55

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

app/ng-ui-widgets-category/tabs/events/article.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,17 @@
22
- `oldIndex` - Provides the old selected index.
33
- `newIndwex` - Provides the new selected index.
44

5-
<snippet id='tabs-events-ng'/>
5+
<snippet id='tabs-events-ng'/>
6+
7+
> **Note:** Any UI event declared throught the HTML markup will be automatically wrapped in the Angular zone. This is not the case when the events are declared thorugh the code behind (e.g., when using `on`) so in such cases we need to manually wrap any event that will be called from a native code:
8+
```TypeScript
9+
constructor(private _zone: NgZone) { }
10+
11+
// .. more code follows here
12+
13+
tabs.on(Tabs.selectedIndexChangedEvent, (data: SelectedIndexChangedEventData) => {
14+
// manually wrapping in the NgZone when using the event via code-behind (otherwise this.selectedIndex won't be updated in the UI)
15+
this._zone.run(() => {
16+
this.selectedIndex = newIndex;
17+
});
18+
});

0 commit comments

Comments
 (0)