Is it possible to manually recompile a directive nested inside another directive?
I have a modal-create-task directive that is initialized using a showCreateTaskModal event together with some data. Based on the data coming with the event the modal change its UI layout and also changes the behavior of a nested directive called search-projects.
The problem I'm having at the moment is that I need to recompile the search-directive because it needs the data coming in with showCreateTaskModal is fired.
This is how the modal template looks like:
<div class="ui modal" id="modalCreateTask" ng-controller="ModalCreateTaskCtrl">
<search-projects oo-filter="{{ mode }}" oo-subject="searchProjectSubject"></search-projects>
</div>
As you can see both the oo-filter and oo-subject attributes are depending on the data attached to the showCreateTaskModal event, but that event is fired only after the compiler goes through the DOM and then the directive has no access to the needed data, so it falls back to default behavior.
This is the search-projects definition:
angular.module('app.ui.search.projects').directive('searchProjects', function(ConfigService)
{
return {
restrict : 'E',
templateUrl : ConfigService.path.views + '/search/projects.html',
scope : {
filter : '@ooFilter',
subject : '=ooSubject'
}
}
});
Edit 1:
As per request I'll try to explain better what I'm doing.
I have a modal that contains another directive that, based on the content of certain variables, should query the server for data whenever the attributes are changing.
I wanted to recompile the directive in order to execute the init() function again.
Making some researches I also noticed that it's possible to use $watch but I don't know if that's a good solution.
$watchto react to change in data. Better than recompiling, for sure$watch. If you want, write down the answer and I'll mark and upvote it.