I have a created a component called popupmessage to show custom message with "ok" and "cancel" button. This i am invoking from another component say component "a" using $compile like below.
a.js has the below code to invoke popupmessagebox:
var dialogBox = $compile('<pop-up-message id="messagebox" message="' + response.data + '" okbutton="' + "true" + '"cancelbutton="' + "false"'"></pop-up-message>')($scope);
$('.data-table').append(dialogBox);
After this i want to reload component "a" on clicking of OK button in popupmessage component. How do i do this?
Reloading of component "a" can be achieved by adding window.location.reload() after the above lines.
but it does not wait until i click "OK" in popupmessage component.
I want to call reload in "a" component after clicking of button "ok" in popupmessage component. How to achieve this?
I'm not sure how
pop-up-messagedirective looks like but I guess it's somehow similar to the code below.Anyway, directive can receive data from whom call it via its attribute, but you already know this because you pass the
messagefor example, to the directive.Directive can receive also functions. So you declare the function in the controller / component, pass it via the attributes, and then you can call it in the directive.
Even if your controller / directive are not looking the same as the example [1], you probably can get the idea of how to implement it.
[1] In the example I used isolated scope. If your directive is not using it, you should declare the
callbackfunction on thescopeyou're passing the directive and it should work the same.