Comments (11)
from angular.
Can you post your root module too?
from angular.
//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 {}
from angular.
OK, that's interesting.
What happens if you change your root module imports (removing FooModule
) to:
imports: [
BrowserModule,
UIRouterModule.forRoot({
useHash: false,
config: function uiRouterConfigFn(router: UIRouter) {
router.urlService.rules.otherwise({ state: 'foo' });
router.stateRegistry.root();
},
}),
BarModule,
],
from angular.
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 FooModule
also contains functionality which is used by a couple of other modules (e.g. a form or something) If I import FooModule
into more than one other module (let's say FooBarModule
uses the FooComponent
) then the duplicate state error occurs again.
The option of moving the reusable forms into a SharedModule
is also not really appealing as I would basically just end up with a giant SharedModule
with a other modules effectively only representing views of the application, which would effectively result in a flat app structure.
from angular.
Agreed, this is a bug that needs to be fixed
from angular.
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
from angular.
I believe this is related to this angular issue: angular/angular#13652
from angular.
Thanks for posting that. I think we can work around the bug by eliminating duplicates when applying the ng module configs
from angular.
@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.
from angular.
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!
from angular.
Related Issues (20)
- Support Angular 11 HOT 1
- Angular 12 HOT 8
- Future of ui-router? HOT 6
- Error: State 'quizzes' is already defined HOT 2
- uiSref doesn't work unless matching "name". Can't use full path/name. HOT 2
- How to lazy load with chunks HOT 11
- Incompatibility with Angular v13 - removal of `NgModuleFactoryLoader` HOT 1
- Angular 13 Support (libs update) and version policy HOT 13
- [Discussion] Monorepo requirements for ui-router packages HOT 11
- Redirects on local anchor reference HOT 2
- onError not redirecting HOT 1
- Angular v14 support HOT 2
- [bug(?)]: future state declaration's data not passed/merged to/with loaded child state HOT 1
- Angular 15 support HOT 5
- MergeInjector breaks normal Angular DI priority HOT 3
- [question] Lazy loaded module empty after creating
- Breaks when building with Angular 16
- Angular 16 support HOT 9
- Angular 17 support HOT 4
- Incorrect Ui Routing on iOS 17 safari private browsing mode.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular.