input/textarea提交内容空格回车转换问题
/*my-enter-bind.js*/
/*回车换行显示转义*/
'use strict'; angular.module('app')
.directive('myEnterBind', function() {
return {
restrict: 'A',
require: '?ngModel',
scope: {
myEnterBind: '='
},
link: function(scope, elem, attrs) {
var value = scope.myEnterBind;
var enterValue = value.replace(new RegExp(/\n/g), '<br>');
var temp = enterValue.replace(new RegExp(/\s/g), ' ');
$(elem).html(temp);
}
}
});
将空格回车转换即可
关于input/textarea默认去除空格 问题
data-ng-trim=“false”属性