New 'resolve' option for defining locals for Dialog controller #182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See: Need resolves with the controller. #85
Allow users to define DI factories for dialog controller locals. I have emulated the specification and implementation of the angular-route $routeProvider 'resolve' option. Hence it supports async values via promises.
This feature is purely an enhancement, so it should not change or break the existing API in any way. To gain some confidence about this I have also added a basic testing setup to the project (karma + jasmine). This includes some rudimentary specs but is not comprehensive by any measure.
Here are what the docs look like for the feature:
resolve {Object.<string, function>=}
An optional map of dependencies which should be injected into the controller.
If any of these dependencies are promises, ngDialog will wait for them all to be resolved
or one to be rejected before the controller is instantiated.
If all the promises are resolved successfully, the values of the resolved promises are
injected.
The map object
is:
key
–{string}
: a name of a dependency to be injected into the controller.factory
-{string|function}
: Ifstring
then it is an alias for a service.Otherwise if function, then it is injected using
$injector.invoke
and the returnvalue is treated as the dependency. If the result is a promise, it is resolved
before its value is injected into the controller.