1

I am using Angular Bootstrap UI in my project.

I have a directive 'HelpDirective', which is used in different controllers. That directive calls HelpService which opens a modal and after it is closed the data is supposed to still remain in the controller model.

But it does not work :(

Here is the template:

<button type="button"
    class="btn btn-link"
    selectedHelp="selectedHelp"
    help-directive>
<span class="fa fa-question"></span> Help
</button>

Here is my directive:

service.directive('helpDirective', ['helpService', function (helpService) {
return {
    restrict: 'A',
    scope: {
        selectedHelp : "="
    },
    link: function (scope, element, attrs) {
        element.click(function (e) {

            e.preventDefault();

            var modal = helpService.openHelpModal(scope.selectedHelp);

             modal.result.then(function (selectedHelp) {
                 console.log(selectedHelp);
                 scope.selectedHelp = selectedHelp;
            });

        });
    }
};
}]);

console.log - gives me the right data. But in controller the data is lost.

naneri
  • 3,771
  • 2
  • 29
  • 53

0 Answers0