var updFileId = "12345";
$scope.compGridJson = {
"peers": ["localhost:7051", "localhost:8051"],
"fcn": "move",
"args": ["compGridDetails", "{" +
"\"FromParty\":\"Valuelabs\",\"CreatedState\":\"24/08/2017\",\"FileUId\":\"+updFileId+\",\"Status\":\"ValueLabs Change Request\"}"
]
}
$http({
method: "POST",
url: "http://localhost:4000/channels/mychannel/chaincodes/changedneww727",
data: $scope.compGridJson,
headers: {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
}
}).success(function(data, status, headers, config) {
}).error(function(data, status, headers, config) {
});
以上是我的代码。在“FileUId”的Json数据中,我正在动态传递数据。但它没有动态获取数据。我为这个价值改变了很多方法,但它不是动态的。我想动态传递“12345”值。可以帮助我。
答案 0 :(得分:2)
字符串连接格式不正确。你应该试试:
$scope.compGridJson = {
"peers": ["localhost:7051", "localhost:8051"],
"fcn": "move",
"args": ["compGridDetails", "{" +
"\"FromParty\":\"Valuelabs\",\"CreatedState\":\"24/08/2017\",\"FileUId\":\""+updFileId+"\",\"Status\":\"ValueLabs Change Request\"}"
]
}
答案 1 :(得分:0)
您应该使用json.stringify()
$scope.compGridJson = {
"peers": ["localhost:7051", "localhost:8051"],
"fcn": "move",
"args": ["compGridDetails", JSON.stringify({
FromParty : "Valuelabs",
CreatedState: "24/08/2017",
FileUId : updFileId,
Status : "ValueLabs Change Request"
})]
}