我已从 json 文件中提取数据。现在它显示在 DOM 上。
在 HTML 页面上,我有三个选项 1) 编辑数据 2) 删除特定数据 & 3) 添加新数据。
如何使用 AngularJS 代码执行此操作?即在编辑名称时,它应该更新我的 JSON 对象。在删除行时,应该删除 JSON 数据中的该行。如果我单击“添加新项”,则输入的数据将添加到 JSON。
我的代码如下。
通过json文件导入数据并显示在DOM上
.controller('MainCtrl', function ($scope, $http) {
$http.get('data/home.json').
success(function(data, status, headers, config) {
$scope.details = data;
}).
error(function(data, status, headers, config) {
// log error
});
});
Output of this code is correct as below image.
JSON Object as below.
{
"status":"success",
"adformat":[
{
"adformat_id":1,
"name":"Format 1",
"size":"300x250"
},
{
"adformat_id":2,
"name":"Format 2",
"size":"320x250"
},
{
"adformat_id":3,
"name":"Format 3",
"size":"320x480"
}
]
}