标签: javascript angularjs
任何想法为什么原生的javascript trim()函数不能用于angularjs?
<input ng-model="myInput"> if($scope.myInput.trim() != ''){ alert('required'); return false; }
答案 0 :(得分:0)
trim()函数没有问题但是,如果要检查一个空字符串,它应该是
trim()
$scope.login = function () { if($scope.myInput.trim() == ''){ alert('required'); } };
工作App
App