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).
But I am needing that the moment PUT completes it calls a certain function that is in another controller.
I wanted to know if there is a possibility to use the $watch in ng-click for when it fires call this function I created
scope.enableEdit = function() {
showAction([
'editNavItem',
'addNavItem',
'editNavItemContent'
]);
};
The problem is because when it adds something in the database it reset the input parameters.
It would not be the case of a service where you centralize the process of insertion and notification?
– OnoSendai
@Onosendai good, I really thought about it as I took the project this way and my client has a certain 'rush' I would need a solution with the current structure. But you’re absolutely right I’ll try to put a flag on the service it returns.
– Edmo
I’m sorry. = / Dirty and fast way - Jete Rootscope, use
broadcast
to announce the update and monitor, in your other control, the event.– OnoSendai
Sample -
$rootScope.$broadcast('nomeDoEvento')
. To monitor the event, use$rootScope.$on('nomeDoEvento', function () {...});
– OnoSendai
It’s really gonna get a little dirty, but I’m gonna try here to keep it going and I’m gonna follow your suggestion with the service thing.
– Edmo
If it works, add your own response demonstrating how you implemented it. I did no more than comment. =)
– OnoSendai