Skip to content

Commit d0ea893

Browse files
author
Ben Grynhaus
committed
Demonstrate custom component inside command bar
1 parent 31b580c commit d0ea893

File tree

4 files changed

+56
-8
lines changed

4 files changed

+56
-8
lines changed

apps/demo/src/app/app.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ <h2>Getting up and running...</h2>
3030
</fab-command-bar-item>
3131
<fab-command-bar-item key="copy" text="Copy" [iconProps]="{ iconName: 'Copy' }" (click)="onCopyClicked()"></fab-command-bar-item>
3232
<fab-command-bar-item key="custom" text="custom text" (click)="onCopyClicked()">
33-
<!-- <render>
33+
<render>
3434
<ng-template let-item="item">
35-
<div>Custom render</div>
35+
<counter></counter>
3636
</ng-template>
37-
</render> -->
37+
</render>
3838

39-
<render-icon>
39+
<!-- <render-icon>
4040
<ng-template let-contextualMenuItemProps="contextualMenuItemProps">
4141
<div>custom icon</div>
4242
</ng-template>
43-
</render-icon>
43+
</render-icon> -->
4444
</fab-command-bar-item>
4545
<fab-command-bar-item *ngIf="runDisabled" key="sometimesVisible" text="woosh"></fab-command-bar-item>
4646
</items>

apps/demo/src/app/app.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export class AppComponent {
6464
onCustomItemClick(item: any) {
6565
this.customItemCount++;
6666
console.log('custom item clicked', item);
67-
this.cd.detectChanges();
6867
}
6968

7069
constructor(private readonly cd: ChangeDetectorRef) {}

apps/demo/src/app/app.module.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,38 @@
11
import { AngularReactBrowserModule } from '@angular-react/core';
2-
import { FabBreadcrumbModule, FabButtonModule, FabCalloutModule, FabModalModule, FabCheckboxModule, FabChoiceGroupModule, FabComboBoxModule, FabCommandBarModule, FabDatePickerModule, FabDialogModule, FabDividerModule, FabFabricModule, FabGroupedListModule, FabIconModule, FabImageModule, FabPanelModule, FabPersonaModule, FabSpinnerModule, FabMessageBarModule, FabLinkModule, FabToggleModule, FabPivotModule, FabHoverCardModule, FabTooltipModule, FabShimmerModule, FabSliderModule, FabSearchBoxModule } from '@angular-react/fabric';
2+
import {
3+
FabBreadcrumbModule,
4+
FabButtonModule,
5+
FabCalloutModule,
6+
FabModalModule,
7+
FabCheckboxModule,
8+
FabChoiceGroupModule,
9+
FabComboBoxModule,
10+
FabCommandBarModule,
11+
FabDatePickerModule,
12+
FabDialogModule,
13+
FabDividerModule,
14+
FabFabricModule,
15+
FabGroupedListModule,
16+
FabIconModule,
17+
FabImageModule,
18+
FabPanelModule,
19+
FabPersonaModule,
20+
FabSpinnerModule,
21+
FabMessageBarModule,
22+
FabLinkModule,
23+
FabToggleModule,
24+
FabPivotModule,
25+
FabHoverCardModule,
26+
FabTooltipModule,
27+
FabShimmerModule,
28+
FabSliderModule,
29+
FabSearchBoxModule,
30+
} from '@angular-react/fabric';
331
import { NgModule } from '@angular/core';
432
import { NxModule } from '@nrwl/nx';
533
import { initializeIcons } from 'office-ui-fabric-react/lib/Icons';
634
import { AppComponent } from './app.component';
35+
import { CounterComponent } from './counter/counter.component';
736

837
@NgModule({
938
imports: [
@@ -37,7 +66,7 @@ import { AppComponent } from './app.component';
3766
FabSliderModule,
3867
FabSearchBoxModule,
3968
],
40-
declarations: [AppComponent],
69+
declarations: [AppComponent, CounterComponent],
4170
bootstrap: [AppComponent],
4271
})
4372
export class AppModule {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Component, OnInit, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
2+
3+
@Component({
4+
selector: 'counter',
5+
template: `
6+
<div>{{ count }}</div>
7+
<button (click)="onClick()">+</button>
8+
`,
9+
changeDetection: ChangeDetectionStrategy.OnPush,
10+
})
11+
export class CounterComponent {
12+
count = 0;
13+
14+
constructor(private readonly cd: ChangeDetectorRef) {}
15+
16+
onClick() {
17+
this.count++;
18+
this.cd.detectChanges();
19+
}
20+
}

0 commit comments

Comments
 (0)