Open ScottChapman opened 8 years ago
No, but it's possible. We need to $watch
open
to update scope.isOpen
when it changes. See here
A pull request is welcome. Make sure you write a test for it.
Seems like an easy fix
Replacing https://github.com/mohsen1/json-formatter/blob/master/src/json-formatter.js#L154
with
scope.$watch('open', function(value) {
scope.isOpen = !!scope.open;
}, false);
I have this working locally and it works well. For now I am copying the json-formatter package locally until this enhancement is merged.
Hello, any chance to fix the code as proposed? This will be really useful...
I'll merge and publish a small PR that only does that. #41 is way too much changes.
Please send a PR.
Now idea about PR. I'm just using your module :) Sorry
Is it possible to fix it. It Will be rally usefull forum my progetto. Thank you!
@ric79 pull requests are welcome! :)
@raygig I modified the library with your suggestion, but now how can i trigger the watcher? I tried to bind the open attribute of the directive and then changing the data model, but the watcher does not get triggered. I did something like this:
<json-formatter open="jsonDepth" json="jsonObj"></json-formatter>
<button ng-click="changeOpen()">CHANGE OPEN</button>
and in my controller:
$scope.jsonObj = my object;
$scope.jsonDepth = 10;
$scope.changeOpen = function() { $scope.jsonDepth = 1; };
The changeOpen function is triggered, but not the watcher. Can someone help? Many thanks in advance
I wanted to implement a mechanism where I would expand/collapse all the JSON Formatters with a button. But I couldn't get it to work.
Is there a way to do that?