So I currently have a directive for dynatree that is working fine. My question is is there a way from a controller to re-invoke a directive so that it rebuilds its self? Since my data is being stored in session storage and the updates to it are massive I can just fetch my new data set, swap it in session storage and rebuild the directive
1 Answer
Within your directive, you can $watch for changes. Your $watch expression can monitor changes as simple as a property change, or it can monitor changes from properties that are several levels deep (deep object changes). You can even monitor according to the evaluation of a function. There is a lot of flexibility when it comes to what the directive watches and when and how to respond to those changes when they occur. For example, when conditions are met for rebuilding the tree (maybe through re-evaluation of a function, or maybe some external function that gets evaluated that changes a property), you can rebuild as you see fit.
$watchto monitor your controller's model, which should allow itself to be rebuilt so to speak.