我有两个文本框Name
和Description
,其中包含两个单独的错误标记。
post create方法在对象数组中的json中返回错误,我想过滤这些消息并检查propertyName
是否Name
然后显示errorMessage
到Name
文本框
<textarea id="txtDescription" ng-model="Description" class="form-control"></textarea>
<label ng-repeat="MyError in errors (want to apply filter here where propertyName is 'Description')" ng-model="Description" ng-show="Descriptionalert">{{MyError.ErrorMessage}}</label>
<textarea id="txtName" ng-model="NAme" class="form-control"></textarea>
<label ng-repeat="MyError in errors (want to apply filter here where propertyName is 'Name')" ng-model="Description" ng-show="Descriptionalert">{{MyError.ErrorMessage}}</label>
.error(function (responseText, status, error) {
$scope.errorvalue = false;
$scope.errors = responseText;
答案 0 :(得分:1)
一种简单的方法是添加ng-if
<div ng-repeat="MyError in errors">
<label ng-if="MyError.PropertyName === 'Description'"></div>
</div>