嗨,以下是我的HTML代码
<th style="width:90px">
<span>ID</span><img class="serverRP_ajax-loader" src="loader_green_32.gif" /><input type="text" id="abc" ng-model="rpFilter.ResourcePlanID.value" />
</th>
我想只在abc文本框中输入一些值时启用loader_green_32.gif。 $ dirty是不可能的,因为我没有使用表单标签
答案 0 :(得分:1)
您可以将ng-if="rpFilter.ResourcePlanID.value"
添加到image tag
。
只有在文本框中输入值时,才会显示该图片。
<th style="width:90px">
<span>ID</span>
<img ng-if="rpFilter.ResourcePlanID.value" class="serverRP_ajax-loader" src="loader_green_32.gif" />
<input type="text" id="abc" ng-model="rpFilter.ResourcePlanID.value" />
</th>
注意:如果您只是想检查是否修改了字段,那么您需要使用$dirty
,为此您必须明确采取formtag
这是怎么回事,
您应该使用属性名称
ng-if="myForm.resourceplanid.$dirty"
<form name="myForm">
<th style="width:90px">
<span>ID</span>
<img ng-if="myForm.resourceplanid.$dirty" class="serverRP_ajax-loader" src="loader_green_32.gif" />
<input type="text" name="resourceplanid" id="abc" ng-model="rpFilter.ResourcePlanID.value" />
</th>
</form>
答案 1 :(得分:1)
<input ng-model="somefield">
<span ng-show="!somefield.length">Please enter something!</span>
<span ng-show="somefield.length">Good boy!</span>
You could also use ng-hide="somefield.length" instead of ng-show="!somefield.length" if that reads more naturally for you.
A better alternative might be to really take advantage of the form abilities of Angular:
<form name="myform">
<input name="myfield" ng-model="somefield" ng-minlength="5" required>
<span ng-show="myform.myfield.$error.required">Please enter something!</span>
<span ng-show="!myform.myfield.$error.required">Good boy!</span>
</form>