这是我想做的事情:
有没有办法在ng-if上检查输入的视图值,还是有更好的解决方案来显示图标?
这是我正在使用的代码(省略了css类):
-HTML:
<form name="form-login">
<input placeholder="email" type="email" ng-model="form.email" required>
<i hm-tap="clearContent('email')",ng-if="form.email.length>0">
<input placeholder="password" type="email" ng-model="form.passwd" required>
<i hm-tap="clearContent('passwd')",ng-if="form.passwd.length>0">
</form>
Run Code Online (Sandbox Code Playgroud)
- 清除coffeescript输入的功能
$scope.clearContent = (fieldName) ->
switch fieldName
when 'passwd' then $scope.form.passwd = ""
when 'email' then $scope.form.email = ""
Run Code Online (Sandbox Code Playgroud)
这适用于密码输入(因为它没有验证).谢谢阅读.