1
- import { Directive , ElementRef , Renderer , Attribute , Optional , Input } from 'angular2/core' ;
1
+ import { Component , ElementRef , Renderer , Attribute , Optional , Input } from 'angular2/core' ;
2
2
3
3
import { Config } from '../../config/config' ;
4
4
import { Toolbar } from '../toolbar/toolbar' ;
@@ -28,8 +28,9 @@ import {Toolbar} from '../toolbar/toolbar';
28
28
* @see {@link /docs/v2/components#buttons Button Component Docs }
29
29
30
30
*/
31
- @Directive ( {
32
- selector : 'button,[button]'
31
+ @Component ( {
32
+ selector : 'button:not([ion-item]),[button]' ,
33
+ template : '<span class="button-inner"><ng-content></ng-content></span>'
33
34
} )
34
35
export class Button {
35
36
private _role : string = 'button' ; // bar-button/item-button
@@ -78,7 +79,6 @@ export class Button {
78
79
}
79
80
80
81
this . _readAttrs ( element ) ;
81
- this . _readIcon ( element ) ;
82
82
}
83
83
84
84
/**
@@ -89,6 +89,7 @@ export class Button {
89
89
if ( this . color ) {
90
90
this . _colors = [ this . color ] ;
91
91
}
92
+ this . _readIcon ( this . _elementRef . nativeElement ) ;
92
93
this . _assignCss ( true ) ;
93
94
}
94
95
@@ -124,6 +125,9 @@ export class Button {
124
125
private _readIcon ( element : HTMLElement ) {
125
126
// figure out if and where the icon lives in the button
126
127
let childNodes = element . childNodes ;
128
+ if ( childNodes . length == 1 ) {
129
+ childNodes = childNodes [ 0 ] . childNodes ;
130
+ }
127
131
let childNode ;
128
132
let nodes = [ ] ;
129
133
for ( let i = 0 , l = childNodes . length ; i < l ; i ++ ) {
@@ -218,9 +222,9 @@ export class Button {
218
222
}
219
223
}
220
224
221
- /**
222
- * @private
223
- */
225
+ /**
226
+ * @private
227
+ */
224
228
static setRoles ( contentButtonChildren , role : string ) {
225
229
let buttons = contentButtonChildren . toArray ( ) ;
226
230
buttons . forEach ( button => {
0 commit comments