I've got a modal with a registration form. The same form should be displayed at the bottom of the landing page not in a modal.
Currently my controller that handles registration modal takes $modalInstance
as one of its parameters along $scope
etc. If I add ng-controller="SignUpCtrl"
to an element in the landing page, it doesn't work, because the controller wasn't created via $modal.open
method and so Angular complains about Unknown provider: $modalInstanceProvider <- $modalInstance
.
I've got a service for registering users (authService.signUp(data).then/catch...)
, but the controller itself does a bit more - handles input, emits events (e.g. with translated error messages), sets cookies etc.
What's the best way to handle such case without duplicating almost whole controller code? Should I move the code from controller into yet another, higher-level service?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…