dart - How to inject services into RouteInitializerFn (new routing DSL) -


I'm switching my app to the new routing DSL. Specifically, I want to do something like this with preEnter :

  last RouteInitializerFn routes = (router router, ViewFactory views) {views.configure ({'chat': ngRoute (Path: '/ chat', // authService.requireState returns a future & lt; bool;, and can call an HttpRequest preEnter: (RoutePreEnterEvent E) => e.allowEnter (authService .requireState (LOGGED_IN), views: views / chat.html '),' Login to ': ngRoute (path:', defaultRoute: true, view: of Ideas / login.html ')}); }  

will be configured in this module:

value (RouteInitializerFn, routes);

If you've missed it, then I'm referring to an inclaimable authService inside RouteInitializerFn . This is not possible because routerinilizerphone is a function and there is no class, so anything can not be injected if I explain the routes function within a square , Then I'm not sure how I can configure RouteInitializerFn , so I'm in some scandals

I found a very good solution to this problem. If you define a call method on a class, you can configure Tunifif as the execution. Very cool Here's my solution:

  class route {end user service _useer service; Routes (this._userService); Zero Call (Router Router, ViewFactory Viewed) {views.configure ({'chat': ngRoute (path: '/ chat', preEnter: (RoutePreEnterEvent e) => e.allowEnter (this._userService.requireUserState ( UserService.LOGGED_IN), see: 'idea / chat.html'), 'login': ngrt (path: '', default path: true, scene: 'view / login')}); }}  

and how it is configured within the module:

// year sentence Type of composition (RouteInitializerFn, implemented by: route); // New Syntax Dam (Root Initialization, Implementation: Roots);

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -