简体   繁体   English

迭代通过对象内的数组

[英]Iterate Through array inside object

Using C# regex i have sent modelState object to the java script and add it in the var type temp. 使用C#regex我已经将modelState对象发送到java脚本并将其添加到var type temp中。 Now this object have multiple arrays with in. 现在这个对象有多个数组。

在此输入图像描述

One way is to specify the key and get all error msgs from this object like 一种方法是指定密钥并从此对象获取所有错误消息

{{modelState["employee.FirstName"][0]}}
{{modelState["employee.Email"][0]}}
{{modelState[".............."][0]}}

There are almost 8 to 10 key pairs that maybe returns and will take time to write all key value. 有大约8到10个密钥对可能会返回,并且需要时间来写入所有密钥值。 How do i iterate from this arrays inside object and get all the errors with out specifying the key value. 我如何从对象内部的这个数组进行迭代,并在没有指定键值的情况下获取所有错误。

You could: 你可以:

var allErrors = [];
$.each( modelState, function( name, errors ){
    allErrors = allErrors.concat(errors); 
} );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM