File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { Directive , ElementRef , Renderer , Attribute } from '@angular/core' ;
2
+
3
+ import { Config } from '../../config/config' ;
4
+
5
+ /**
6
+ * @name Chip
7
+ * @module ionic
8
+ * @description
9
+ * Chips represent complex entities in small blocks, such as a contact.
10
+ * @see {@link /docs/v2/components/#chips Chips Component Docs }
11
+ **/
12
+
13
+ @Directive ( {
14
+ selector : 'ion-chip'
15
+ } )
16
+ export class Chip {
17
+
18
+ constructor (
19
+ config : Config ,
20
+ private _elementRef : ElementRef ,
21
+ private _renderer : Renderer
22
+ ) {
23
+ let element = _elementRef . nativeElement ;
24
+
25
+ this . _readAttrs ( element ) ;
26
+ }
27
+
28
+ /**
29
+ * @private
30
+ */
31
+ private _readAttrs ( element : HTMLElement ) {
32
+ let elementAttrs = element . attributes ;
33
+ let attrName : string ;
34
+
35
+ console . info ( "mushroom" ) ;
36
+
37
+ for ( let i = 0 , l = elementAttrs . length ; i < l ; i ++ ) {
38
+ if ( elementAttrs [ i ] . value !== '' ) continue ;
39
+
40
+ attrName = elementAttrs [ i ] . name ;
41
+
42
+ // Ignore attributes item-left, item-right
43
+ if ( attrName . indexOf ( 'item' ) === - 1 ) {
44
+ this . _setClass ( attrName ) ;
45
+ }
46
+ }
47
+ }
48
+
49
+ /**
50
+ * @private
51
+ */
52
+ private _setClass ( color : string ) {
53
+ this . _renderer . setElementClass ( this . _elementRef . nativeElement , 'chip-' + color , true ) ;
54
+ }
55
+ }
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ import { NavPush } from '../components/nav/nav-push';
46
46
import { NavbarTemplate , Navbar } from '../components/navbar/navbar' ;
47
47
import { ShowWhen , HideWhen } from '../components/show-hide-when/show-hide-when' ;
48
48
import { Typography } from '../components/typography/typography' ;
49
+ import { Chip } from '../components/chip/chip' ;
49
50
50
51
/**
51
52
* @private
@@ -67,6 +68,7 @@ import { Typography } from '../components/typography/typography';
67
68
* - MenuClose
68
69
* - Badge
69
70
* - Button
71
+ * - Chip
70
72
* - Content
71
73
* - Scroll
72
74
* - InfiniteScroll
@@ -131,6 +133,7 @@ export const IONIC_DIRECTIVES: any[] = [
131
133
Backdrop ,
132
134
Badge ,
133
135
Button ,
136
+ Chip ,
134
137
Content ,
135
138
Scroll ,
136
139
InfiniteScroll ,
You can’t perform that action at this time.
0 commit comments