Currently, I'm using ng-jsoneditor.
I'm trying to toggle the state from editable to read-only.
To set the readonly property I have to specify the onEditable property of the options property. For instance:
$scope.obj = {
data: json,
options: {
mode: 'tree',
onEditable: function(){return false;}
}
};
I am able to get the changeOptions property to toggle the mode property, however I cannot get the onEditable property to toggle. I want the user to have the capability to edit the json while in the 'code' mode. This is what I tried:
$scope.changeOptions = function () {
$scope.obj.options.mode = $scope.obj.options.mode == 'tree' ? 'code' : 'tree';
$scope.obj.options.onEditable = $scope.obj.options.onEditable == function(){return false;} ? function(){return true;} : function(){return false;};
};