AngularJS: Passing Parameters From One Directive To Another Directive

Before I begin, shout out to my co-worker Will for figuring this out.

We have a directive where there are two select drop-downs that user can select. I wanted to create another directive that's on that same view to grab the two select values the user selected for the directive I was writing. In order to do this we were able to capture it using $watchGroup:

$scope.$watchGroup(['firstSelect', 'secondSelect'], function (newValues, oldValues) {
    // Do whatever you need to do
    // firstSelect and secondSelect are the values from the first directive

This is what the first directive HTML looks like:

<select ng-model="firstSelect" ng-options="a.Id as for a in itemsOne"></select>  
<select ng-model="secondSelect" ng-options="b.Id as for b in itemsTwo"></select>  
Show Comments