我有使用ng-disabled的问题它可以正常使用chrome和firefox,但 IE 11
的问题<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>My first app</title>
</head>
<body ng-app="myApp" ng-controller="myController as vm">
<input type="text" ng-model="vm.name" />
<button ng-disabled="vm.isBtnDisabled()">Button</button>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script>
var app=angular.module("myApp",[]);
app.controller("myController",["$scope", function($scope){
this.name="";
this.isBtnDisabled=function(){
return this.name.trim().length==0;
}
}]);
</script>
</body>
</html>
如果我犯了任何错误,请告诉我。谢谢。
答案 0 :(得分:0)
您可以添加原型方法scope.$watch
以使用IE11
changes
trim
&#13;
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
}
&#13;