我想channel_name_1自动增加并channel_name_2,channel_name_3;if 语句去哪里
看//THİS LİNE
"{\"channel_list\": {\"channel_name_1\": \"deneme\", \"channel_name_0\": \">Ev s\u0131cakl\u0131k takibi\", \"channel_id_0\": 136, \"channel_id_1\": 137}}">
我想接受channel_name_1,channel_name_0价值观。
感谢到现在
var veri;
var headers = new Headers();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json' );
//headers.append('Authorization' , 'Basic '+ btoa(tok));
let options = new RequestOptions({ headers: headers });
let postParams = {
token: "381f13d7056-ce5fe474919",
user_id: "71",
}
var veris="channel_name_";
this.http.post("https://iothook.com/api/v1.0/channels/", postParams, options)
.subscribe(data => {
veri = data['_body'];
console.log(veri);
veri= veri.slice(1, -1);
veri = veri.replace(/\/g, "");
veri = JSON.parse(veri);
for(var i = 0 ; i<2;i++)
{
veris+=i;
this.veriler.push({channelname: veri.channel.channel_name_1}); //THİS LİNE
console.log(veri.channel_name_1);
}
}, error => {
console.log(error);// Error getting the data
});
我不确定你在问什么,但我认为你想使用括号符号,就像这样:
for(var i = 0; i < 2; i++){
veris += i;
this.veriler.push({ channelname: veri.channel['channel_name_' + (i + 1) }); //THİS LİNE
console.log(veri.channel['channel_name_' + (i + 1));
}