Lets say I have the following view code:
<button ng-click="login()">Login</button>
If I would like to pass a callback from the view into the controllers login method, how would I do that?
I want to do something like:
<button ng-click="login( function() {
$('#loginDialog').modal('hide');
} )">Log in</button>
But angular won't parse that code in ng-click so it won't work.
What I want to do is to separate out DOM manipulation from the controllers and into callbacks that the controllers can call. Thus, making the controller more testable.
I do know there is a dialog service for angular but lets pretend the usecase isn't dialogs, just some other DOM altering stuff.
Do I have to resort to service injection and register all callbacks in a service and inject that service into my controller? I would like to have the injection as method injection instead of constructor injection here.
So is there any way to do something like what I've described above?