mohsen1 / json-formatter

Angular directive for collapsible JSON in HTML
http://azimi.me/json-formatter/demo/demo.html
Other
372 stars 85 forks source link

Added a watch on 'open' for dynamic open changes #41

Open tysenmoore-xse opened 8 years ago

tysenmoore-xse commented 8 years ago

This is a simple change to implement #34. I am a little green at some of this stuff so this may not be the best approach. I tested the changes with simple collapse all/none buttons and they seemed to work well--redrew the content when a button was pressed.

mohsen1 commented 8 years ago

For this a simple $watch should be enough

scope.$watch('open', function(value) { scope.isOpen = !!value; }); 
tysenmoore-xse commented 8 years ago

I only modified the src version, I was unclear if the dist version was generated as well as the minified versions. Let me know if there is more integration needed.

tysenmoore-xse commented 8 years ago

I treated it as a singleton because I was not sure if the watch would be added on every link phase. If you'd prefer I could remove the singleton approach.

mohsen1 commented 8 years ago

The singleton won't help much here.

DmitryEfimenko commented 8 years ago

any update on this? Dynamic open attr would be fantastic

mohsen1 commented 8 years ago

My plan is to use json-formatter-js for internally in this directive (#35) . That will make this directive a thin wrapper around the core lib. If you have time to do it I'll help merging and releasing it.

raygig commented 7 years ago

Any chance we can have the watched open attribute? Whats the status of this?