-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(popup): pass context to popup open method
Closes #1145
- Loading branch information
1 parent
4554855
commit 87d569b
Showing
13 changed files
with
156 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
demo/src/app/components/popover/demos/tplwithcontext/popover-tplwithcontext.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<p> | ||
You can optionally pass in a context when manually triggering a popover. | ||
</p> | ||
|
||
<template #popContent let-greeting="greeting">{{greeting}}, <b>{{name}}</b>!</template> | ||
<p> | ||
How would you like to greet <strong [ngbPopover]="popContent" popoverTitle="Greeting" #p="ngbPopover" triggers="manual">me</strong>? | ||
</p> | ||
<button type="button" class="btn btn-secondary" (click)="changeGreeting({ greeting: 'Bonjour' })"> | ||
French | ||
</button> | ||
<button type="button" class="btn btn-secondary" (click)="changeGreeting({ greeting: 'Gutentag' })"> | ||
German | ||
</button> | ||
<button type="button" class="btn btn-secondary" (click)="changeGreeting({ greeting: 'Hello' })"> | ||
English | ||
</button> |
22 changes: 22 additions & 0 deletions
22
demo/src/app/components/popover/demos/tplwithcontext/popover-tplwithcontext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {NgbPopover} from '@ng-bootstrap/ng-bootstrap'; | ||
import {Component, ViewChild} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'ngbd-popover-tplwithcontext', | ||
templateUrl: './popover-tplwithcontext.html' | ||
}) | ||
export class NgbdPopoverTplwithcontext { | ||
greeting = {}; | ||
name = 'World'; | ||
|
||
@ViewChild('p') public popover: NgbPopover; | ||
|
||
public changeGreeting(greeting: any): void { | ||
const isOpen = this.popover.isOpen(); | ||
this.popover.close(); | ||
if (greeting !== this.greeting || !isOpen) { | ||
this.greeting = greeting; | ||
this.popover.open(greeting); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
demo/src/app/components/tooltip/demos/tplwithcontext/tooltip-tplwithcontext.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<p> | ||
You can optionally pass in a context when manually triggering a popover. | ||
</p> | ||
|
||
<template #tipContent let-greeting="greeting">{{greeting}}, <b>{{name}}</b>!</template> | ||
<p> | ||
How would you like to greet <strong [ngbTooltip]="tipContent" #t="ngbTooltip" triggers="manual">me</strong>? | ||
</p> | ||
<button type="button" class="btn btn-secondary" (click)="changeGreeting({ greeting: 'Bonjour' })"> | ||
French | ||
</button> | ||
<button type="button" class="btn btn-secondary" (click)="changeGreeting({ greeting: 'Gutentag' })"> | ||
German | ||
</button> | ||
<button type="button" class="btn btn-secondary" (click)="changeGreeting({ greeting: 'Hello' })"> | ||
English | ||
</button> |
22 changes: 22 additions & 0 deletions
22
demo/src/app/components/tooltip/demos/tplwithcontext/tooltip-tplwithcontext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {NgbTooltip} from '@ng-bootstrap/ng-bootstrap'; | ||
import {Component, ViewChild} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'ngbd-tooltip-tplwithcontext', | ||
templateUrl: './tooltip-tplwithcontext.html' | ||
}) | ||
export class NgbdTooltipTplwithcontext { | ||
greeting = {}; | ||
name = 'World'; | ||
|
||
@ViewChild('t') public tooltip: NgbTooltip; | ||
|
||
public changeGreeting(greeting: any): void { | ||
const isOpen = this.tooltip.isOpen(); | ||
this.tooltip.close(); | ||
if (greeting !== this.greeting || !isOpen) { | ||
this.greeting = greeting; | ||
this.tooltip.open(greeting); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters