-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
State 'foo' is already defined - [email protected] #42
Comments
Can you post your root module too? |
//app/app.module.ts
import { LocationStrategy, PathLocationStrategy, Location } from '@angular/common';
import { SystemJsNgModuleLoader, NgModuleFactoryLoader, NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { UIRouterModule, UIRouter } from 'ui-router-ng2';
import FooModule from './foo/foo.module';
import BarModule from './bar/bar.module';
import AppComponent from './app.component';
@NgModule({
imports: [
BrowserModule,
UIRouterModule.forRoot({
useHash: false,
config: function uiRouterConfigFn(router: UIRouter) {
router.urlService.rules.otherwise({ state: 'foo' });
router.stateRegistry.root();
},
}),
FooModule,
BarModule,
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ],
providers: [
{ provide: LocationStrategy, useClass: PathLocationStrategy },
{ provide: NgModuleFactoryLoader, useClass: SystemJsNgModuleLoader },
{ provide: Location, useClass: Location },
],
})
export class AppModule {} |
OK, that's interesting. imports: [
BrowserModule,
UIRouterModule.forRoot({
useHash: false,
config: function uiRouterConfigFn(router: UIRouter) {
router.urlService.rules.otherwise({ state: 'foo' });
router.stateRegistry.root();
},
}),
BarModule,
], |
Thanks for looking into this! That does make the error go away, however I'd prefer to not have to do that long term as The option of moving the reusable forms into a |
Agreed, this is a bug that needs to be fixed |
I'm unable to reproduce this error. Can you please reproduce it for me? I've got an angular-cli project started here: https://github.com/christopherthielen/foo-is-already-defined Run |
I'll try to get a working repo for you this weekend.
…On Thu, Feb 9, 2017 at 8:19 AM Chris Thielen ***@***.***> wrote:
I'm unable to reproduce this error. Can you please reproduce it for me?
I've got an angular-cli project started here:
https://github.com/christopherthielen/foo-is-already-defined
Run ng serve
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#42 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABYoIp5nac4fK1HfLVQeVWpxNsQmxwyxks5rayBkgaJpZM4L7Wxd>
.
|
I believe this is related to this angular issue: angular/angular#13652 |
Thanks for posting that. I think we can work around the bug by eliminating duplicates when applying the ng module configs |
@jspizziri I think I have a fix for this, but I can't test it without a reproduction. I'm going to push the change, and when I do will close the issue. If it's not fixed we can reopen. |
Thanks for working on this! Sorry I wasn't able to get you a reproduction. Once the fix is pushed, I'll make sure to let you know if it does or does not fix the issue in our repository. Thanks again! |
This is a duplicate issue of angular-ui/ui-router#3326, as I wasn't sure where the appropriate place to file it was. Upon upgrading my app to
[email protected]
I started receiving a duplicate state declaration error in the following situation.If I have two modules:
In this case I receive a runtime error stating
State 'foo' is already defined
, as a result of addingFooModule
to the list of imports inBarModule
. I'm not sure if this is intended behavior, however this is not how the router behaves in[email protected]
The text was updated successfully, but these errors were encountered: