Skip to content

Commit bfea263

Browse files
crisbetoandrewseguin
authored andcommitted
chore: remove change detection toggle from demo app (#6444)
Removes the toggle that changes the change detection in the demo app. It's not needed anymore since all components use OnPush.
1 parent 6422640 commit bfea263

File tree

3 files changed

+4
-45
lines changed

3 files changed

+4
-45
lines changed

src/demo-app/demo-app/demo-app.html

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
<div class="demo-toolbar">
3131
<h1>Angular Material Demos</h1>
3232
<div>
33-
<button md-button (click)="toggleChangeDetection()" title="Toggle change detection">
34-
Change detection: {{changeDetectionStrategy}}
35-
</button>
3633
<button md-icon-button (click)="toggleFullscreen()" title="Toggle fullscreen">
3734
<md-icon class="md-24">fullscreen</md-icon>
3835
</button>
@@ -44,14 +41,8 @@ <h1>Angular Material Demos</h1>
4441
</div>
4542
</md-toolbar>
4643

47-
<div #root="dir" dir="ltr" class="demo-content" [ngSwitch]="changeDetectionStrategy">
48-
<div *ngSwitchDefault>
49-
<router-outlet></router-outlet>
50-
</div>
51-
52-
<demo-app-on-push *ngSwitchCase="'OnPush'">
53-
<router-outlet></router-outlet>
54-
</demo-app-on-push>
44+
<div #root="dir" dir="ltr" class="demo-content">
45+
<router-outlet></router-outlet>
5546
</div>
5647
</div>
5748
</md-sidenav-container>

src/demo-app/demo-app/demo-app.ts

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ import {
22
Component,
33
ViewEncapsulation,
44
ElementRef,
5-
ChangeDetectionStrategy,
65
Renderer2,
76
} from '@angular/core';
87
import {OverlayContainer} from '@angular/material';
98

10-
const changeDetectionKey = 'mdDemoChangeDetection';
11-
129
/**
1310
* The entry app for demo site. Routes under `accessibility` will use AccessibilityDemo component,
1411
* while other demos will use `DemoApp` component. Since DemoApp and AccessibilityDemo use
@@ -35,15 +32,6 @@ export class EntryApp {}
3532
})
3633
export class Home {}
3734

38-
@Component({
39-
moduleId: module.id,
40-
selector: 'demo-app-on-push',
41-
template: '<ng-content></ng-content>',
42-
changeDetection: ChangeDetectionStrategy.OnPush,
43-
encapsulation: ViewEncapsulation.None,
44-
})
45-
export class DemoAppOnPush {}
46-
4735
/**
4836
* DemoApp with toolbar and sidenav.
4937
*/
@@ -56,7 +44,6 @@ export class DemoAppOnPush {}
5644
})
5745
export class DemoApp {
5846
dark = false;
59-
changeDetectionStrategy: string;
6047
navItems = [
6148
{name: 'Autocomplete', route: '/autocomplete'},
6249
{name: 'Button', route: '/button'},
@@ -97,14 +84,7 @@ export class DemoApp {
9784
constructor(
9885
private _element: ElementRef,
9986
private _renderer: Renderer2,
100-
private _overlayContainer: OverlayContainer) {
101-
// Some browsers will throw when trying to access localStorage in incognito.
102-
try {
103-
this.changeDetectionStrategy = window.localStorage.getItem(changeDetectionKey) || 'Default';
104-
} catch (error) {
105-
console.error(error);
106-
}
107-
}
87+
private _overlayContainer: OverlayContainer) {}
10888

10989
toggleFullscreen() {
11090
let elem = this._element.nativeElement.querySelector('.demo-content');
@@ -119,17 +99,6 @@ export class DemoApp {
11999
}
120100
}
121101

122-
toggleChangeDetection() {
123-
try {
124-
this.changeDetectionStrategy = this.changeDetectionStrategy === 'Default' ?
125-
'OnPush' : 'Default';
126-
window.localStorage.setItem(changeDetectionKey, this.changeDetectionStrategy);
127-
window.location.reload();
128-
} catch (error) {
129-
console.error(error);
130-
}
131-
}
132-
133102
toggleTheme() {
134103
const darkThemeClass = 'unicorn-dark-theme';
135104

src/demo-app/demo-app/demo-module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
22
import {CommonModule} from '@angular/common';
33
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
44
import {RouterModule} from '@angular/router';
5-
import {DemoApp, DemoAppOnPush, Home} from './demo-app';
5+
import {DemoApp, Home} from './demo-app';
66
import {DEMO_APP_ROUTES} from './routes';
77
import {ProgressBarDemo} from '../progress-bar/progress-bar-demo';
88
import {ContentElementDialog, DialogDemo, IFrameDialog, JazzDialog} from '../dialog/dialog-demo';
@@ -65,7 +65,6 @@ import {TableHeaderDemo} from '../table/table-header-demo';
6565
CheckboxDemo,
6666
DatepickerDemo,
6767
DemoApp,
68-
DemoAppOnPush,
6968
DialogDemo,
7069
GesturesDemo,
7170
GridListDemo,

0 commit comments

Comments
 (0)