我将此字段用于编辑 View 和创建 View
<input data-ng-model="userInf.username" class="span12 editEmail" type="text" placeholder="me@example.com" pattern="[^@]+@[^@]+\.[a-zA-Z]{2,6}" required />
在 Controller 中我有这个代码来禁用输入元素:
function($rootScope, $scope, $location, userService)
{
//etc
$(".editEmail" ).attr("disabled", disable); // no idea how to do in angular
}
请帮忙。
最佳答案
使用ng-disabled或带有 ng-class 的特殊 CSS 类
<input data-ng-model="userInf.username"
class="span12 editEmail"
type="text"
placeholder="me@example.com"
pattern="[^@]+@[^@]+\.[a-zA-Z]{2,6}"
required
ng-disabled="{expression or condition}"
/>
关于javascript - 如何使用 angular.js 禁用输入框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17402294/