InputTextDirective class
The UI portion of the ng-model directive. This directive registers the UI events and provides a rendering function for the ng-model directive.
@NgDirective(selector: 'input[type=text][ng-model]') class InputTextDirective { dom.InputElement inputElement; NgModel ngModel; Scope scope; InputTextDirective(dom.Element this.inputElement, NgModel this.ngModel, Scope this.scope) { ngModel.render = (value) { if (value == null) value = ''; var currentValue = inputElement.value; if (value == currentValue) return; var start = inputElement.selectionStart; var end = inputElement.selectionEnd; inputElement.value = value; inputElement.selectionStart = start; inputElement.selectionEnd = end; }; inputElement.onChange.listen(relaxFnArgs(processValue)); inputElement.onKeyDown.listen((e) => new async.Timer(Duration.ZERO, processValue)); } processValue() { var value = inputElement.value; if (value != ngModel.viewValue) { scope.$apply(() => ngModel.viewValue = value); } } }
Constructors
new InputTextDirective(Element inputElement, NgModel ngModel, Scope scope) #
Creates a new Object instance.
Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.
docs inherited from Object
InputTextDirective(dom.Element this.inputElement, NgModel this.ngModel, Scope this.scope) { ngModel.render = (value) { if (value == null) value = ''; var currentValue = inputElement.value; if (value == currentValue) return; var start = inputElement.selectionStart; var end = inputElement.selectionEnd; inputElement.value = value; inputElement.selectionStart = start; inputElement.selectionEnd = end; }; inputElement.onChange.listen(relaxFnArgs(processValue)); inputElement.onKeyDown.listen((e) => new async.Timer(Duration.ZERO, processValue)); }
Properties
InputElement inputElement #
dom.InputElement inputElement
Methods
dynamic processValue() #
processValue() { var value = inputElement.value; if (value != ngModel.viewValue) { scope.$apply(() => ngModel.viewValue = value); } }