私は value.Job
を行うことはできませんので、私は列の名前を知らない、foreachループでこだわっている、と私はそれを具体的なデータジェネリックforeachのJavaScriptでループとAngularJs
the Object N° 1
the column name is Name : Matt
the column name is Job : Teacher
the Object N° 2
the column name is Name : Alice
the column name is Job : Doctor
任意のアイデア:
angular.forEach(data, function(value, key) {
console.log('the Object N° ' + i);
'maybe another loop for all the column
console.log('the column name is + ': ' + value ??);
});
結果は次のようにする必要があります!
JavaScriptとAngularJs forEachの両方のオプションが必要です。 IVEはArray.forEach
を使用しますが、angular.forEach
はほぼ同じ構造を持っています
var data = [
{Name: "Matt", Job: "Teacher"},
{Name: "Alice", Job: "Doctor"}];
data.forEach(function(e,i){
console.log(i);
for(var key in e){
console.log(key + ':' + e[key]);
}
});
注意を次のように
は、あなたがのサンプルを共有することができますあなたのデータの構造d? – EranSch
'i' varとは何ですか? – nolan
カラム名はどこに保存されていますか? – Roysh