javascript - How prevent angular version earlier than 1.3.0 auto trim for fields? -


is there way prevent angular version earlier 1.3.0 auto trim fields in whole application? know can prevent specified field using ngtrim directive, doesn't add directive text fields in application, there way fields in angular module? here code, if add add spaces in begin of input not appear in label:

<div ng-app>   <div ng-controller="todoctrl">       {{field}}     <input type="text" ng-model="field">   </div> </div> 

also here link first question how prevent angular auto trim fields?, answer there working angular 1.3.0 or later versions.

in angular prior 1.3.x can try decorate compile function:

app.config(function($provide) {     $provide.decorator('inputdirective', function($delegate) {          var directive = $delegate[0];          directive.compile = function(orig) {             return function(element, attrs, transclude) {                 attrs.$set('ngtrim', 'false');                 return orig.apply(null, arguments);             };         }(directive.compile);          return $delegate;     }); }); 

this approach should work in 1.3.x though.

demo: http://plnkr.co/edit/gvia7omifwwoww9tyl4s?p=preview


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -