angularjs - angular service available at configuration phase -
I want to move some repetitive arguments into the reuse service, which is assigned to a configuration step Should be available in . And possibly there can be access to To be specific, when I define my routes with the To reach your service provider in the config block, it should work just fine: The crystal is not clear on what I am looking for you, but it 'just works' Note, service registration to jsbins: I've now added a somehow example how you The following can: It should include the specified requirements: JSBIN: and I hope this will be enough for you, and you can give some idea about creating your own $ xxxProvider dependency injection Is such a thing possible? Can this be done with the factory / provider / service / continuous?
ui-router , I found that the paths for the CRUD are all the same, except for the names of the resources I want to move this argument to configure a CRUD route to make root definitions more dry.
app.service ('myService', function (/ * dependencies / /) {// service content. Return this;}); App.config (function ($ rendered) {$ provide.decorator ('myService', function ($ representative) {// $ representative refers to 'myService'. // You can modify its behavior and here No. Representative;});});
config needs to come before the block if they live in the same file. One way to overcome this is to remove your service in a separate module and to inject it as the dependency of your main module. Something like this:
var serviceModule = angular.module ('service module', []); ServiceModule.service ('myService', function () {}); Var main module = angular Modules ('Main', ['Service Module']); MainModule.config (function ($ rendered) {$ .decorator ('myService', function ($ representative) {});});
edit
provider in your own provider Inject, passing through a constructor from one constructor to another
provider .
provider for shortcodes, and how they differ. As you can see clearly, the
provider main functions provide the most options for this - but for obvious reasons it is also hard to work together.
$ stateProvider extension! I'm trying my best to write code in JSBIN to make it easy to understand how it keeps all relationships together.
Comments
Post a Comment