forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolbar-item.ts
More file actions
40 lines (34 loc) · 976 Bytes
/
toolbar-item.ts
File metadata and controls
40 lines (34 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { ContentChildren, Directive, ElementRef, forwardRef, Optional, Inject, Renderer } from '@angular/core';
import { Button } from '../button/button';
import { Config } from '../../config/config';
import { Ion } from '../ion';
import { Navbar } from '../navbar/navbar';
import { Toolbar } from './toolbar';
/**
* @private
*/
@Directive({
selector: 'ion-buttons,[menuToggle]'
})
export class ToolbarItem extends Ion {
inToolbar: boolean;
constructor(
config: Config,
elementRef: ElementRef,
renderer: Renderer,
@Optional() toolbar: Toolbar,
@Optional() @Inject(forwardRef(() => Navbar)) navbar: Navbar
) {
super(config, elementRef, renderer);
this._setMode('bar-buttons', config.get('mode'));
this.inToolbar = !!(toolbar || navbar);
}
@ContentChildren(Button)
set _buttons(buttons: any) {
if (this.inToolbar) {
buttons.forEach((button: Button) => {
button.setRole('bar-button');
});
}
}
}