2018-02-10 15:18:01 +00:00
|
|
|
import ngModule from '../../module';
|
2018-03-01 15:52:35 +00:00
|
|
|
import './style.scss';
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2018-02-21 10:41:22 +00:00
|
|
|
class Icon {
|
|
|
|
constructor($attrs) {
|
|
|
|
this.$attrs = $attrs;
|
|
|
|
this._icon = null;
|
|
|
|
}
|
|
|
|
set icon(value) {
|
|
|
|
this._icon = value;
|
|
|
|
this.drawIcon();
|
|
|
|
}
|
|
|
|
get icon() {
|
|
|
|
return this._icon;
|
|
|
|
}
|
|
|
|
drawIcon() {
|
|
|
|
if (this.icon.startsWith('icon-')) {
|
|
|
|
this.iconClass = this.icon;
|
|
|
|
this.iconContent = '';
|
|
|
|
} else {
|
|
|
|
this.iconClass = 'material-icons';
|
|
|
|
this.iconContent = this.icon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Icon.$inject = ['$attrs'];
|
|
|
|
|
2018-02-10 15:18:01 +00:00
|
|
|
ngModule.component('vnIcon', {
|
2018-02-21 10:41:22 +00:00
|
|
|
template: '<i class="{{::$ctrl.iconClass}}">{{::$ctrl.iconContent}}</i>',
|
|
|
|
controller: Icon,
|
2017-06-13 11:08:06 +00:00
|
|
|
bindings: {
|
|
|
|
icon: '@'
|
2017-06-15 13:00:43 +00:00
|
|
|
}
|
2017-06-13 11:08:06 +00:00
|
|
|
});
|