![](/img/trans.png)
[英]How to perform Add, Edit and Delete operations for JSON data using AngularJS?
[英]How to edit and validate JSON data using angularjs?
您需要直接在范圍內聲明“ obj”對象
app.controller('MainCtrl', function($scope,$http) {
$scope.JSONFiles = [];
$scope.obj = {data: '', options: { mode: 'tree' }};
$http.get("test1.json").success(function (response) {
$scope.JSONFiles.push(response);
});
$http.get("test2.json").success(function (response) {
$scope.JSONFiles.push(response);
});
$scope.selectedjson ="";
$scope.textAreaData = "";
$scope.optionChanged = function(){
$scope.textAreaData = $scope.selectedjson;
// alert($scope.textAreaData);//gives selected file json data
// code to implement json-editor
$scope.obj = {data: $scope.textAreaData, options: {mode: 'tree'}};
$scope.onLoad = function (instance) {
instance.expandAll();
};
$scope.changeOptions = function () {
$scope.obj.options.mode = $scope.obj.options.mode == 'tree' ? 'code' : 'tree';
};
};
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.