gpt4 book ai didi

javascript - json 返回对象数组,如何为 Angular $scope 变量赋值?

转载 作者:行者123 更新时间:2023-12-03 10:00:49 27 4
gpt4 key购买 nike

我有两个文本框 NameDescription,它们有两个单独的错误标签。

post create 方法返回对象数组中的 json 错误,我想过滤这些消息并检查 propertyName 是否为 Name 然后显示 errorMessageName 文本框。

  <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;

enter image description here

最佳答案

一个简单的方法是添加ng-if

<div ng-repeat="MyError in errors">
<label ng-if="MyError.PropertyName === 'Description'"></div>
</div>

关于javascript - json 返回对象数组,如何为 Angular $scope 变量赋值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30609428/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com