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 $ xxxProvider dependency injection Is such a thing possible? Can this be done with the factory / provider / service / continuous?

To be specific, when I define my routes with the 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.

To reach your service provider in the config block, it should work just fine:

  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;});});   

The crystal is not clear on what I am looking for you, but it 'just works'

Note, service registration to 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) {});});   

jsbins:

edit

I've now added a somehow example how you The following can:

  1. Register your own custom provider manufacturer, which gives the object
  2. Another provider in your own provider Inject, passing through a constructor from one constructor to another
  3. Register a secondary service, which is not available Is injected into Rmata
  4. app.config .
  5. Inject an example given by the manufacturer in a controller
  6. Exchanging the end data with the example given by the consultant, with Argos.

    It should include the specified requirements:

    • Publish the DI, provider provider .
    • From Prone Di, from services
    • Available during the config phase.

      JSBIN:

      and 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.

      I hope this will be enough for you, and you can give some idea about creating your own $ 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

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -