salix/front/core/components/textarea/index.js

38 lines
902 B
JavaScript

import ngModule from '../../module';
import Field from '../field';
import './style.scss';
export default class Textarea extends Field {
constructor($element, $scope, $compile) {
super($element, $scope, $compile);
let html = `<textarea ng-model="$ctrl.field"></textarea>`;
this.input = this.$compile(html)($scope)[0];
}
set rows(value) {
this.input.rows = typeof value == 'number' && value > 0 ? value : 3;
}
get rows() {
return this.input.rows;
}
set maxlength(value) {
let length = typeof value == 'number' && value > 1 ? value : 50;
this.input.setAttribute('maxlength', length);
}
get maxlength() {
return this.input.getAttribute('maxlength', length);
}
}
ngModule.vnComponent('vnTextarea', {
controller: Textarea,
bindings: {
rows: '<?',
maxlength: '<?'
}
});