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

37 lines
879 B
JavaScript
Raw Normal View History

2019-10-09 22:47:29 +00:00
import ngModule from '../../module';
import Field from '../field';
export default class Textarea extends Field {
constructor($element, $scope, $compile) {
super($element, $scope, $compile);
let html = `<textarea ng-model="$ctrl.field"></textarea>`;
2019-10-28 20:40:24 +00:00
this.input = this.$compile(html)($scope)[0];
2019-10-09 22:47:29 +00:00
}
set rows(value) {
this.input.rows = typeof value == 'number' && value > 0 ? value : 3;
}
get rows() {
return this.input.rows;
}
2020-01-14 08:10:54 +00:00
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);
}
2019-10-09 22:47:29 +00:00
}
ngModule.vnComponent('vnTextarea', {
controller: Textarea,
bindings: {
2020-01-14 08:10:54 +00:00
rows: '<?',
maxlength: '<?'
2019-10-09 22:47:29 +00:00
}
});