javascript - Getting Error: Unkown provider: $urlMatcherFactory -


unkown provider: $urlmatcherfactory  

this error message angular throws when try inject $urlmatcherfactory in app config.

i have included ui-router js file , have been using last few months.

i need this:

var datematcher = $urlmatcherfactory.compile("/day/{start:date}"); $stateprovider.state('calendar.day', {     url: datematcher  }); 

as this example shows.

normally code won't identify $urlmatcherfactory. tried injecting dependency on config error.

in q&a matching url array list of words in angularjs ui-router can see how use $urlmatcherfactory. link working plunker .

in example, $urlmatcherfactory used in .run():

  .run(['$urlmatcherfactory',     function($urlmatcherfactory) {        var sourcelist= ['john', 'paul', 'george', 'ringo']       var names = sourcelist.join('|');       var urlmatcher = $urlmatcherfactory.compile("/{source:(?:" + names + ")}/:id");        $stateproviderref          .state('names', {            url: urlmatcher,           templateurl: 'tpl.root.html',           controller: 'myctrl'         });     }   ]); 

and mean, if use in config phase, should ask $urlmatcherfactoryprovider (see provider @ end)

but: using providers in config phase means - can configure them. mean configure provider itself. later evaluable (already configured) in run phase

configuring providers

you may wondering why bother set full-fledged provider provide method if factory, value, etc. easier. answer providers allow lot of configuration. we've mentioned when create service via provider (or of shortcuts angular gives you), create new provider defines how service constructed. didn't mention these providers can injected config sections of application can interact them!

first, angular runs application in two-phases--the config , run phases. config phase, we've seen, can set providers necessary. directives, controllers, filters, , set up. run phase, might guess, angular compiles dom , starts app.


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -