I have an instruction that is used as a form control. This instruction is hidden in a modal dialog and it is shown that when the user clicks on a button to show the form, since this instruction connects to some web services, I do not want to start it unless the user displays buttons and forms Does not (to stop unnecessary web service calls) So, what I see is a good way for the original controller to trigger instructions for executing some init code. Here's an example:
App.controller ('parentCtrl', ['$ scope', function ($ radius)) {$ scope.onButtonClick = onButtonClick function) {// Instructions Init Somehow);}]); App.directive ('myDirective', function () {return {restrict: 'E', scope: {}, Controller: function ($ scope, myService) {function init ()} {myService.getData (. Value) { // do init luggage})}}}});
The template for parentCtrl contains a tag.
tagging a ng-if
before your element requires directive Will stop from starting. ( scope.loadModal
should be incorrect by default)
& lt; My-directive ng-if = 'loadModal' & gt; & Lt; / Mydirective & gt;
Note: Setting scope.loadModal = false
after showing the instructions will unload the Directorate from your DOM once. Setting it back to the right will reload the instructions, resulting in another http request.
Comments
Post a Comment