salix/front/core/components/label-value/label-value.js

37 lines
895 B
JavaScript

import ngModule from '../../module';
import './style.scss';
export default class Controller {
constructor($element, $translate) {
this.element = $element[0];
this._ = $translate;
}
set label(value) {
let label = this.element.querySelector('vn-label');
label.textContent = this._.instant(value);
this._label = value;
}
get label() {
return this._label;
}
set value(value) {
let span = this.element.querySelector('span');
span.title = value;
span.textContent = value ? value : '-';
this._value = value;
}
get value() {
return this._value;
}
}
Controller.$inject = ['$element', '$translate'];
ngModule.component('vnLabelValue', {
controller: Controller,
template: require('./label-value.html'),
bindings: {
label: '@',
value: '@'
}
});