[英]material design angular input require
Does Angular Material Design require an input ng-model to be equal to a variable in order for required to work? Angular Material Design是否要求输入ng模型等于变量才能满足要求?
Without using Material Design, the following error checking works perfectly fine. 不使用Material Design,以下错误检查完全正常。
<label>First Name (as it appears on your card)</label>
<input type="text" name="firstName" data-ng-model="test" required/>
Using Material Design though, the following always returns invalid unless the user types something, deletes it, and types something else. 但是,使用Material Design时,除非用户键入内容,删除它并键入其他内容,否则以下内容始终返回无效。
<md-input-container>
<label>First Name (as it appears on your card)</label>
<input type="text" name="firstName" data-ng-model="test" required/>
</md-input-container>
However, I set test equal to something in the scope, then error checking works fine: 但是,我将测试设置为范围内的某些内容,然后错误检查工作正常:
$scope.test = 'this value';
Is there a way to error check using Material Design without needing to specify a default value for fields? 有没有办法使用Material Design进行错误检查而无需为字段指定默认值?
I think you might not have initialized the ng-model variable in the controller. 我想你可能没有在控制器中初始化ng-model变量。
Try initializing the variable, $scope.test = '';
尝试初始化变量
$scope.test = '';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.