-2
*檢查dashboardCtrl.js和整合與最終的JSON數據格式以下窗口小部件(開始getDashboard()函數:整合自己的小工具angularjs
- 第一
- 謝勝利
- 第三*
我應該寫這樣的嗎?
$ http.get(Dashboard)function(){}?或功能getDashboard(){} 如果有人知道如何整合,請發送給我鏈接,謝謝
*檢查dashboardCtrl.js和整合與最終的JSON數據格式以下窗口小部件(開始getDashboard()函數:整合自己的小工具angularjs
- 第一
- 謝勝利
- 第三*
我應該寫這樣的嗎?
$ http.get(Dashboard)function(){}?或功能getDashboard(){} 如果有人知道如何整合,請發送給我鏈接,謝謝
您沒有足夠的信息來幫助我們。但是,如果您被要求將某些內容整合/合併到 JSON中,請使用$ http.post()。舉個例子:
// Some data to send
var my_data = {"widgets":[{"widget1":""},{"widget2":""},{"widget3":""}],"JSONfile":"file.json"};
$http.post(url,my_data).then(function(result){
/* Success */
}, function(error){
/* Error */
});
打開和修改JSON,你可以使用PHP:
<?php
/* Get the data from POST request
$dataReceived = file_get_contents('php://input');
$myFile = json_decode($dataReceived);
$myWidget = $myFile->widgets;
$JSON_file_name = $myFile->JSONfile;
*/
$content = json_decode(file_get_contents($JSON_file_name), true);
$content['content'][] = ['widget'=>$myWidget];
$newJsonString = json_encode($content, JSON_UNESCAPED_SLASHES);
file_put_contents($JSON_file_name, $newJsonString);
?>
從JSON檢索數據:
$http.get(url).then(function(result){
$scope.my_data = result.data;
}, function(error){
/* Error */
$scope.my_data = null;
});
謝謝你,現在我undertand一切 – MargeKh