title: AngularJS JSON Editor toggle editable
body: <p>Currently, I'm using <a href="https://github.com/angular-tools/ng-jsoneditor" rel="nofollow noreferrer">ng-jsoneditor</a>. </p>
  
  <p>I'm trying to toggle the state from editable to read-only. </p>
  
  <p>To set the readonly property I have to specify the <code>onEditable</code> property of the <code>options</code> property. For instance:</p>
  
  <pre><code> $scope.obj = {
              data: json, 
              options: {
                  mode: 'tree',
                  onEditable: function(){return false;}
              }
    };
  </code></pre>
  
  <p>I am able to get the <code>changeOptions</code> property to toggle the <code>mode</code> property, however I cannot get the <code>onEditable</code> property to toggle. I want the user to have the capability to edit the json while in the <code>'code'</code> mode. This is what I tried:</p>
  
  <pre><code>    $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;};
      };
  </code></pre>
  
  <p><a href="http://jsfiddle.net/sd3at5ek/298/" rel="nofollow noreferrer">JsFiddle Example</a></p>