javascript - AngularJS not able to type in textbox -
at moment try implement app angularjs. @ first problem: not able type text textbox.
i have zoomservice increments , decrements zoom property. user able zoom slider, buttons , textbox unfortunatelly part textbox doesn't work.
here code:
"use strict"; app.service("zoomservice", ["$rootscope", function ($rootscope) { var data = { zoom: 100, upperbound: 200, // todo: aus konfigurationsdatei lesen lowerbound: 20 // todo: aus konfigurationsdatei lesen }; return { data: data, increment: function() { if ($rootscope.$root.$$phase != "$apply" && $rootscope.$root.$$phase != "$digest") { $rootscope.$apply(function() { if (data.zoom + 1 <= data.upperbound) data.zoom++; }); } else { if (data.zoom + 1 <= data.upperbound) data.zoom++; } }, decrement: function() { if ($rootscope.$root.$$phase != "$apply" && $rootscope.$root.$$phase != "$digest") { $rootscope.$apply(function () { if (data.zoom - 1 >= data.lowerbound) data.zoom--; }); } else { if (data.zoom - 1 >= lowerbound) data.zoom--; } }, reset: function() { if ($rootscope.$root.$$phase != "$apply" && $rootscope.$root.$$phase != "$digest") { $rootscope.$apply(function () { data.zoom = 100; }); } else { data.zoom = 100; } } } }]); app.controller("startcontroller", ["$scope", "zoomservice", function($scope, zoomservice) { $scope.zoom = zoomservice; }]); <div data-ng-show="project.data.project !== null" class="zoom top-right"> <div> <form name="zoomform" data-ng-init="setformscope(this)"> <img src="/styles/images/16x16/fi_verkleinern.png" data-ng-click="zoom.decrement()" alt="zoom -" title="zoom -" /> <input class="slider" type="range" min="{{zoom.data.lowerbound}}" max="{{zoom.data.upperbound}}" data-ng-model="zoom.data.zoom" /> <img src="/styles/images/16x16/fi_vergroessern.png" data-ng-click="zoom.increment()" alt="zoom +" title="zoom +"/> <input name="directzoom" type="text" data-ng-minlength="2" data-ng-maxlength="3" data-ng-pattern="/^[0-9]{2,3}$/" data-ng-model="zoom.data.zoom" data-ng-model-options="{updateon: 'blur'}" data-ng-keyup="cancel($event)" /> </form> </div> </div> i happy every small hint solve problem. in advance!
there parent element (md-select in case) eating key down events. fix this, try adding onkeydown="event.stoppropagation()" input tag. prevent event reaching parent element, can't call preventdefault() anymore.
example:
<input type="text" ng-model="zoom.data.zoom" ... onkeydown="event.stoppropagation()" /> if doesn't work, try looking other code might calling preventdefault() , eating keydown events.
it's possible have logic reverting model value original value type. check ng-change or $watch events might doing this. although not issue if use {updateon: 'blur'}.
Comments
Post a Comment