bug fixed: login
This commit is contained in:
parent
22f2d3e7f3
commit
c90be5bd04
|
@ -3,16 +3,18 @@
|
|||
class="mdl-textfield__input"
|
||||
type="{{$ctrl.type}}"
|
||||
name="{{$ctrl.name}}"
|
||||
ng-model="{{$ctrl.model}}"
|
||||
vn-validation="{{$ctrl.rule}}"
|
||||
ng-disabled="{{$ctrl.disable}}"/>
|
||||
ng-model="$ctrl.value"
|
||||
vn-validation="$ctrl.rule"
|
||||
ng-disabled="$ctrl.disable"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="mdl-chip__action"
|
||||
tabindex="-1"
|
||||
translate-attr="{title: 'Clear'}"
|
||||
style="visibility: hidden">
|
||||
style="visibility: hidden"
|
||||
>
|
||||
<i class="material-icons">clear</i>
|
||||
</button>
|
||||
<label class="mdl-textfield__label" translate="{{$ctrl.label}}"></label>
|
||||
<label class="mdl-textfield__label">{{$ctrl.label | translate}}</label>
|
||||
</div>
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
import { module } from '../module';
|
||||
|
||||
import Component from '../lib/component';
|
||||
// import * as resolveFactory from '../lib/resolveDefaultComponents';
|
||||
// import * as normalizerFactory from '../lib/inputAttrsNormalizer';
|
||||
import './style.scss';
|
||||
// import './textfield.mdl';
|
||||
|
||||
export default class TextfieldController {
|
||||
export default class TextfieldController extends Component {
|
||||
constructor($element, $scope, $attrs) {
|
||||
super($element);
|
||||
|
||||
this.$scope = $scope;
|
||||
this.$attrs = $attrs;
|
||||
let input = this.input = this.$element.querySelector('input');
|
||||
this.$element = $element[0];
|
||||
|
||||
let input = this.input = $element[0].querySelector('input');
|
||||
|
||||
input.addEventListener('input',
|
||||
() => this.checkValue());
|
||||
input.addEventListener('focus',
|
||||
|
@ -27,7 +31,17 @@ export default class TextfieldController {
|
|||
let div = this.$element.firstChild;
|
||||
componentHandler.upgradeElement(div);
|
||||
|
||||
Object.assign(this, $attrs);
|
||||
this._value = null;
|
||||
|
||||
this.type = this.$attrs.type || 'text';
|
||||
}
|
||||
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
set value(value) {
|
||||
this._value = (value === undefined || value === '') ? null : value;
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
|
@ -37,9 +51,10 @@ export default class TextfieldController {
|
|||
this.$scope.$watch(this.$attrs.model,
|
||||
() => mdlTextField.updateClasses_());
|
||||
|
||||
let $input = angular.$element(this.input);
|
||||
$input.controller('ng-model').$parsers.push(value => value === '' ? null : value);
|
||||
/* let $input = angular.element(this.input);
|
||||
$input.controller('ng-model').$parsers.push(value => value === '' ? null : value);*/
|
||||
}
|
||||
|
||||
onClearClick() {
|
||||
this.input.value = null;
|
||||
this.checkValue();
|
||||
|
@ -48,23 +63,21 @@ export default class TextfieldController {
|
|||
event.initEvent('change', false, true);
|
||||
this.input.dispatchEvent(event);
|
||||
}
|
||||
|
||||
checkValue() {
|
||||
this.showClear(this.input.value);
|
||||
}
|
||||
|
||||
showClear(show) {
|
||||
show = show && document.activeElement === this.input;
|
||||
show = (show && document.activeElement === this.input);
|
||||
let clearButton = this.$element.querySelector('button');
|
||||
clearButton.style.visibility = show ? 'visible' : 'hidden';
|
||||
}
|
||||
/**
|
||||
* Selects the textfield.
|
||||
*/
|
||||
|
||||
select() {
|
||||
this.input.select();
|
||||
}
|
||||
/**
|
||||
* Puts the focus on the textfield.
|
||||
*/
|
||||
|
||||
focus() {
|
||||
this.input.focus();
|
||||
}
|
||||
|
@ -73,5 +86,8 @@ TextfieldController.$inject = ['$element', '$scope', '$attrs'];
|
|||
|
||||
module.component('vnTextfield', {
|
||||
template: require('./textfield.html'),
|
||||
controller: TextfieldController
|
||||
controller: TextfieldController,
|
||||
bindings: {
|
||||
value: '=model'
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue