GithubHelp home page GithubHelp logo

Comments (5)

Asone avatar Asone commented on April 20, 2024 2

found this in the changelog.md of ui-router-ng2 :

BREAKING CHANGE: You no longer configure a module using an Injectable UIRouterConfig class. Now you use a function that receives the UIRouter and the Injector

In 1.0.0-beta.3 you might have a config class like this:

export class MyUIRouterConfig {
  constructor(@Inject(UIRouter) router: UIRouter, @Inject(SomeService) myService: SomeService) {
    // do something with router and injected service
  }
}

which was wired into the root module like this:
```js
@NgModule({
  imports: [
    UIRouterModule.forRoot({ configClass: MyUIRouterConfig })
  ]
})
export class AppModule {}

In 1.0.0-beta.4 you should switch to a simple function.
The function receives the router: UIRouter and injector: Injector

export function configureModule(router: UIRouter, injector: Injector) {
  // do something with router
  router.urlService.rules.type('slug', slugParamType);
  // inject other services
  const myService: SomeService = injector.get(SomeService);
  // do something injected service
  myService.init();
}

which is now wired using config: configureModule instead of configClass: ...

@NgModule({
  imports: [
    UIRouterModule.forRoot({ configClass: MyUIRouterConfig })
  ]
})
export class AppModule {}

from quickstart-ng2.

liangtongxie avatar liangtongxie commented on April 20, 2024

+1

from quickstart-ng2.

Asone avatar Asone commented on April 20, 2024

+1

from quickstart-ng2.

Asone avatar Asone commented on April 20, 2024

you can still make the quickstart work changing ui-router version to 1.0.0-beta3.

Go to your package.json and replace :

"ui-router-ng2": "^1.0.0-beta.3"

with

"ui-router-ng2": "1.0.0-beta.3"

Then run npm install to update the version. It should work

from quickstart-ng2.

christopherthielen avatar christopherthielen commented on April 20, 2024

Yep, the configClass wasn't working nicely with angular DI. Instead, just pass a function as config: configFn which will receive the UIRouter instance.

from quickstart-ng2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.