checkbox component noew emits change event

This commit is contained in:
Joan Sanchez 2019-02-15 08:02:29 +01:00
parent cf9831473b
commit e373e603bf
1 changed files with 10 additions and 4 deletions

View File

@ -1,8 +1,10 @@
import ngModule from '../../module';
import Component from '../../lib/component';
import './style.scss';
export default class Controller {
constructor($attrs) {
export default class Controller extends Component {
constructor($element, $scope, $attrs) {
super($element, $scope);
this.hasInfo = Boolean($attrs.info);
this.info = $attrs.info || null;
}
@ -13,6 +15,10 @@ export default class Controller {
value = false;
this._field = value;
if (this._checkValue !== undefined && this._checkValue !== null)
this.emit('change', {value: this.field});
this._checkValue = value;
}
@ -32,7 +38,7 @@ export default class Controller {
}
checkIntermediate() {
if ((this.intermediate || (this._field === false && this.tripleState)) && !this.isIntermediate) {
if ((this.intermediate || (!this._field && this.tripleState)) && !this.isIntermediate) {
this.isIntermediate = true;
return;
}
@ -40,7 +46,7 @@ export default class Controller {
this.isIntermediate = false;
}
}
Controller.$inject = ['$attrs'];
Controller.$inject = ['$element', '$scope', '$attrs'];
ngModule.component('vnCheck', {
template: require('./check.html'),