angularjs最强大之处之一,数据双向绑定。项目中常用到的两个是ng-bind和ng-model.
ng-bind 针对普通模块进行绑定、ng-model针对form表单进型绑定。
<td> <input type="number" class="form-control" name="mobile" ng-model="newModel.mobile" ng-maxlength="11" /> <span class="text-danger" ng-show="form.mobile.$dirty && form.mobile.$invalid"> <small class="text-danger" ng-show="form.mobile.$error.maxlength"> <i class="fa fa-exclamation-triangle"></i> 移动电话不能超过11个字符 </small> </span> </td>
<span ng-if="selectedItems.length == 0" class="selected-items"> <span ng-bind="defaultLabel"></span> </span> <span ng-if="selectedItems.length > 0" class="selected-items"> <span ng-repeat="selectedItem in selectedItems" class="selected-item">{{selectedItem.name}} <span class="selected-item-close" ng-click="deselectItem(selectedItem, $event)"></span></span> <!--<span class="caret"></span>--> </span>