本文介绍了如何prevent角版本低于1.3.0自动微调的领域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法prevent角版本在整个应用领域从早期的汽车内饰1.3.0?我知道我可以prevent它使用ngTrim指令指定领域,但它并不好看这个指令的应用程序添加到所有文本字段,有没有办法做到这一点的角度模块中的各个领域?这里是code,如果添加的输入开始,他们将不会出现在标签添加空格:

Is there any way prevent angular version earlier 1.3.0 from auto trim for fields in the whole application? I know that I can prevent it for specified field using ngTrim directive, but it doesn't look good add this directive to all text fields in the application, is there any way do it for all fields in the angular module? Here is code, if you add add spaces in the begin of input they will not appear in label:

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

另外这里的链接,我的第一个问题<一href=\"http://stackoverflow.com/questions/30533568/how-$p$pvent-angular-auto-trim-for-fields/30537393#30537393\">How字段的prevent角汽车内饰?,答案有工作角度1.3.0或更高版本。

Also here is link for my first question How prevent angular auto trim for fields?, the answer there is working for angular 1.3.0 or later versions.

推荐答案

在角之前的1.3.x中,你可以尝试装饰编译功能:

In Angular prior to 1.3.x you can try to 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;
    });
});

这方法也应在1.3.x中工作,但

This approach should also work in 1.3.x though.

演示:

这篇关于如何prevent角版本低于1.3.0自动微调的领域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 03:17