watch on a ng-click

2

I have the following input:

 <input type="submit" value="Publish" 
 ng-click="submit(editAddNotification)" project-focus-invalid-field>

When I run it it inserts the change into my database (a PUT).

However, I need to call a certain function that is in another controller at the moment of completing the PUT.

I would like to know if there is a possibility to use $ watch in ng-click for when it triggers call this function that I created

scope.enableEdit = function() {
                    showAction([
                        'editNavItem',
                        'addNavItem',
                        'editNavItemContent'
                    ]);
                };

The problem happens because when it adds something to the database it resets the input parameters.

    
asked by anonymous 09.12.2014 / 13:52

1 answer

0

After checking several options, I decided to use the $ broadcast, but as @OnoSendai said it would be something very dirty, not to get so dirty so I created a service for the broadcast, this way whenever I want to call $rooscope.$broadcast or $rootScope.$on I just instantiate my service and make use of it. You can check the code here, basically I created a pubSub with a pubSub.dispath and a pubSub.addListener understand the first as what it will be looking at and if modified will notify the second that something happened there.

I will not post the code here because it would be too long, but anyone interested in it here has a gist a> that contains the "broadcast" service and anyone who has any improvement or doubt is available. Thank you all.

    
12.12.2014 / 19:28