私は自分のアプリケーションで1つのHTTP getコールを呼び出しています。その値をvaliableに割り当てることで、その結果を角度ツリーに設定しています。Angularjsの値設定問題
$http({
method : "GET",
url : "/getTreeData"
}).then(function mySucces(response) {
//var uriString = JSON.parse(response);//parseReturn(response);
console.log(response);
var res=response.data;
var responseRefactor1=res.replace(new RegExp("123---", 'g'), "[{");
//.replace("/123---/gi", "[{");
var responseRefactor2=responseRefactor1.replace(new RegExp("1234----", 'g'), "}]");
//replace("/1234----/gi", "}]");
console.log(responseRefactor2);
$scope.roleList = responseRefactor2;
}, function myError(response) {
$scope.roleList = '{}';
});
しかし、それはのようないくつかの例外を投げ:
angular.js:10103 Error: [ngRepeat:dupes] http://errors.angularjs.org/1.2.27/ngRepeat/dupes?p0=node%20in%20roleList&p1=string%3Ae&p2=%22e%22
しかし、私はHTTP GETコールを使用せずに直接結果を代入していたときに、それが正常に動作しています。
$scope.roleList=[{
"lebel": "Vehicle Tree",
"children": [{
"lebel": "Corp_Ads",
"children": [{
"lebel": "2016-12-Dec",
"children": [{
"lebel": "HEB Plus",
"children": [{
"lebel": "PSS_BF04Dec16",
"children": "[]",
"id": "PSS_BF04Dec16"
},
{
"lebel": "PSS_18Dec16",
"children": "[]",
"id": "PSS_18Dec16"
}],
"id": "HEB Plus"
},
{
"lebel": "Ethnic Ads",
"children": [{
"lebel": "WO_14Dec16_STY",
"children": "[]",
"id": "WO_14Dec16_STY"
},
{
"lebel": "WO_28Dec16_STY",
"children": "[]",
"id": "WO_28Dec16_STY"
},
{
"lebel": "WO_12Dec16_AAN",
"children": "[]",
"id": "WO_12Dec16_AAN"
}],
"id": "Ethnic Ads"
},
{
"lebel": "San Antonio WPP",
"children": [{
"lebel": "WPPS_14Dec16",
"children": "[]",
"id": "WPPS_14Dec16"
},
{
"lebel": "WPPS_21Dec16",
"children": "[]",
"id": "WPPS_21Dec16"
},
{
"lebel": "WPPS_07Dec16",
"children": "[]",
"id": "WPPS_07Dec16"
},
{
"lebel": "WPPS_28Dec16",
"children": "[]",
"id": "WPPS_28Dec16"
}],
"id": "San Antonio WPP"
},
{
"lebel": "Joe V's",
"children": [{
"lebel": "WPP_JV07Dec16",
"children": "[]",
"id": "WPP_JV07Dec16"
},
{
"lebel": "WPP_JV14Dec16",
"children": "[]",
"id": "WPP_JV14Dec16"
},
{
"lebel": "WPP_JV28Dec16",
"children": "[]",
"id": "WPP_JV28Dec16"
}],
"id": "Joe V's"
},
{
"lebel": "Houston WPP",
"children": [{
"lebel": "WPPH_21Dec16",
"children": "[]",
"id": "WPPH_21Dec16"
},
{
"lebel": "WPPH_28Dec16",
"children": "[]",
"id": "WPPH_28Dec16"
}],
"id": "Houston WPP"
},
{
"lebel": "Corp Ads",
"children": [{
"lebel": "WO_14Dec16_CSB",
"children": "[]",
"id": "WO_14Dec16_CSB"
},
{
"lebel": "WO_21Dec16_CSB",
"children": "[]",
"id": "WO_21Dec16_CSB"
}],
"id": "Corp Ads"
},
{
"lebel": "Mi Tienda",
"children": [{
"lebel": "WPP_MT28Dec16",
"children": "[]",
"id": "WPP_MT28Dec16"
}],
"id": "Mi Tienda"
}],
"id": "2016-12-Dec"
},
{
"lebel": "2016-10-Oct",
"children": [{
"lebel": "Primo Pick",
"children": [{
"lebel": "MTAB__PP_05Oct16",
"children": "[]",
"id": "MTAB__PP_05Oct16"
}],
"id": "Primo Pick"
},
{
"lebel": "HEB Plus",
"children": [{
"lebel": "PSS_02Oct16",
"children": "[]",
"id": "PSS_02Oct16"
},
{
"lebel": "PSS_23Oct16",
"children": "[]",
"id": "PSS_23Oct16"
},
{
"lebel": "PSS_BF23Oct16",
"children": "[]",
"id": "PSS_BF23Oct16"
}],
"id": "HEB Plus"
},
{
"lebel": "Ethnic Ads",
"children": [{
"lebel": "WO_24Oct16_AAN",
"children": "[]",
"id": "WO_24Oct16_AAN"
},
{
"lebel": "WO_10Oct16_AAN",
"children": "[]",
"id": "WO_10Oct16_AAN"
},
{
"lebel": "WO_19Oct16_STY",
"children": "[]",
"id": "WO_19Oct16_STY"
},
{
"lebel": "WO_26Oct16_STY",
"children": "[]",
"id": "WO_26Oct16_STY"
}],
"id": "Ethnic Ads"
},
{
"lebel": "San Antonio WPP",
"children": [{
"lebel": "WPPS_26Oct16",
"children": "[]",
"id": "WPPS_26Oct16"
},
{
"lebel": "WPPS_05Oct16",
"children": "[]",
"id": "WPPS_05Oct16"
}],
"id": "San Antonio WPP"
},
{
"lebel": "Joe V's",
"children": [{
"lebel": "WPP_JV05Oct16",
"children": "[]",
"id": "WPP_JV05Oct16"
},
{
"lebel": "WPP_JV19Oct16",
"children": "[]",
"id": "WPP_JV19Oct16"
}],
"id": "Joe V's"
},
{
"lebel": "Corp Ads",
"children": [{
"lebel": "WO_05Oct16_CSB",
"children": "[]",
"id": "WO_05Oct16_CSB"
},
{
"lebel": "WO_26Oct16_CSB",
"children": "[]",
"id": "WO_26Oct16_CSB"
}],
"id": "Corp Ads"
},
{
"lebel": "Houston WPP",
"children": [{
"lebel": "WPPH_19Oct16",
"children": "[]",
"id": "WPPH_19Oct16"
},
{
"lebel": "WPPH_26Oct16",
"children": "[]",
"id": "WPPH_26Oct16"
}],
"id": "Houston WPP"
},
{
"lebel": "Mi Tienda",
"children": [{
"lebel": "WPP_MT26Oct16",
"children": "[]",
"id": "WPP_MT26Oct16"
},
{
"lebel": "WPP_MT05Oct16",
"children": "[]",
"id": "WPP_MT05Oct16"
}],
"id": "Mi Tienda"
},
{
"lebel": "Grand Opening",
"children": [{
"lebel": "GO_26Oct16_KW",
"children": "[]",
"id": "GO_26Oct16_KW"
}],
"id": "Grand Opening"
}],
"id": "2016-10-Oct"
},
{
"lebel": "2016-11-Nov",
"children": [{
"lebel": "Primo Pick",
"children": [{
"lebel": "MTAB_PP_02Nov16",
"children": "[]",
"id": "MTAB_PP_02Nov16"
},
{
"lebel": "MTAB_PP_30Nov16",
"children": "[]",
"id": "MTAB_PP_30Nov16"
}],
"id": "Primo Pick"
},
{
"lebel": "Black Friday",
"children": [{
"lebel": "PSS_24Nov16_BF",
"children": "[]",
"id": "PSS_24Nov16_BF"
}],
"id": "Black Friday"
},
{
"lebel": "HEB Plus",
"children": [{
"lebel": "PSS_27Nov16",
"children": "[]",
"id": "PSS_27Nov16"
},
{
"lebel": "PSS_BF27Nov16",
"children": "[]",
"id": "PSS_BF27Nov16"
}],
"id": "HEB Plus"
},
{
"lebel": "Ethnic Ads",
"children": [{
"lebel": "WO_07Nov16_AAN",
"children": "[]",
"id": "WO_07Nov16_AAN"
},
{
"lebel": "WO_30Nov16_STY",
"children": "[]",
"id": "WO_30Nov16_STY"
},
{
"lebel": "WO_23Nov16_STY",
"children": "[]",
"id": "WO_23Nov16_STY"
}],
"id": "Ethnic Ads"
},
{
"lebel": "San Antonio WPP",
"children": [{
"lebel": "WPPS_09Nov16",
"children": "[]",
"id": "WPPS_09Nov16"
},
{
"lebel": "WPPS_02Nov16",
"children": "[]",
"id": "WPPS_02Nov16"
}],
"id": "San Antonio WPP"
},
{
"lebel": "Joe V's",
"children": [{
"lebel": "WPP_JV02Nov16",
"children": "[]",
"id": "WPP_JV02Nov16"
},
{
"lebel": "WPP_JV09Nov16",
"children": "[]",
"id": "WPP_JV09Nov16"
}],
"id": "Joe V's"
},
{
"lebel": "Mi Tienda",
"children": [{
"lebel": "WPP_MT02Nov16",
"children": "[]",
"id": "WPP_MT02Nov16"
},
{
"lebel": "WPP_MT30Nov16",
"children": "[]",
"id": "WPP_MT30Nov16"
}],
"id": "Mi Tienda"
},
{
"lebel": "Corp Ads",
"children": [{
"lebel": "WO_02Nov16_CSB",
"children": "[]",
"id": "WO_02Nov16_CSB"
},
{
"lebel": "WO_16Nov16_CSB",
"children": "[]",
"id": "WO_16Nov16_CSB"
}],
"id": "Corp Ads"
},
{
"lebel": "Houston WPP",
"children": [{
"lebel": "WPPH_09Nov16",
"children": "[]",
"id": "WPPH_09Nov16"
},
{
"lebel": "WPPH_02Nov16",
"children": "[]",
"id": "WPPH_02Nov16"
}],
"id": "Houston WPP"
},
{
"lebel": "Grand Opening",
"children": [{
"lebel": "GO_09Nov16_KW",
"children": "[]",
"id": "GO_09Nov16_KW"
},
{
"lebel": "GO_30Nov16_AL",
"children": "[]",
"id": "GO_30Nov16_AL"
},
{
"lebel": "GO_16Nov16_KW",
"children": "[]",
"id": "GO_16Nov16_KW"
}],
"id": "Grand Opening"
}],
"id": "2016-11-Nov"
}],
"id": "Corp_Ads"
}],
"id": "Vehicle Tree"
}];
あなたは$インデックスでトラックを使用してみましたが? – Karim
は1つしか追加できませんでしたが、追跡できませんでした。同じエラーが表示される –