Angular 6 Import a component with same from different paths in a module
up vote
0
down vote
favorite
Just out of curiosity.
I have a component with name MyComponent
at src/module/Component1
folder.
I have a another component with name MyComponent
at src/module/Component2 folder.
Now, How do I import both of them in a module ? Is there some aliasing available for imports ?
import { MyComponent } from '@app/src/module/Component1/mycomponent.component';
// How Do I do this ?
//import { MyComponent } from '@app/src/module/Component2/mycomponent.component';
@NgModule({
imports: [
CommonModule,
SharedModule, ComponentsModule,
FormsModule,
],
declarations: [MyComponent], // I want to declare the second Component also here
providers:
})
export class SampleServerModule { }
If I don't include the second component, I get below error which is correct because I am not including it;
Cannot determine the module for class src/module/Component2/MyComponent
angular angular6
add a comment |
up vote
0
down vote
favorite
Just out of curiosity.
I have a component with name MyComponent
at src/module/Component1
folder.
I have a another component with name MyComponent
at src/module/Component2 folder.
Now, How do I import both of them in a module ? Is there some aliasing available for imports ?
import { MyComponent } from '@app/src/module/Component1/mycomponent.component';
// How Do I do this ?
//import { MyComponent } from '@app/src/module/Component2/mycomponent.component';
@NgModule({
imports: [
CommonModule,
SharedModule, ComponentsModule,
FormsModule,
],
declarations: [MyComponent], // I want to declare the second Component also here
providers:
})
export class SampleServerModule { }
If I don't include the second component, I get below error which is correct because I am not including it;
Cannot determine the module for class src/module/Component2/MyComponent
angular angular6
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Just out of curiosity.
I have a component with name MyComponent
at src/module/Component1
folder.
I have a another component with name MyComponent
at src/module/Component2 folder.
Now, How do I import both of them in a module ? Is there some aliasing available for imports ?
import { MyComponent } from '@app/src/module/Component1/mycomponent.component';
// How Do I do this ?
//import { MyComponent } from '@app/src/module/Component2/mycomponent.component';
@NgModule({
imports: [
CommonModule,
SharedModule, ComponentsModule,
FormsModule,
],
declarations: [MyComponent], // I want to declare the second Component also here
providers:
})
export class SampleServerModule { }
If I don't include the second component, I get below error which is correct because I am not including it;
Cannot determine the module for class src/module/Component2/MyComponent
angular angular6
Just out of curiosity.
I have a component with name MyComponent
at src/module/Component1
folder.
I have a another component with name MyComponent
at src/module/Component2 folder.
Now, How do I import both of them in a module ? Is there some aliasing available for imports ?
import { MyComponent } from '@app/src/module/Component1/mycomponent.component';
// How Do I do this ?
//import { MyComponent } from '@app/src/module/Component2/mycomponent.component';
@NgModule({
imports: [
CommonModule,
SharedModule, ComponentsModule,
FormsModule,
],
declarations: [MyComponent], // I want to declare the second Component also here
providers:
})
export class SampleServerModule { }
If I don't include the second component, I get below error which is correct because I am not including it;
Cannot determine the module for class src/module/Component2/MyComponent
angular angular6
angular angular6
asked Nov 11 at 8:47
Abdul Rehman Sayed
4,20042448
4,20042448
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
As explained in the documentation, imports can be renamed:
import { MyComponent as MyOtherComponent } from ...
add a comment |
up vote
0
down vote
import { MyComponent as NewNameYouWantToUse } from '@app/src/module/Component2/mycomponent.component';
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
As explained in the documentation, imports can be renamed:
import { MyComponent as MyOtherComponent } from ...
add a comment |
up vote
1
down vote
accepted
As explained in the documentation, imports can be renamed:
import { MyComponent as MyOtherComponent } from ...
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
As explained in the documentation, imports can be renamed:
import { MyComponent as MyOtherComponent } from ...
As explained in the documentation, imports can be renamed:
import { MyComponent as MyOtherComponent } from ...
answered Nov 11 at 8:53
JB Nizet
530k51855988
530k51855988
add a comment |
add a comment |
up vote
0
down vote
import { MyComponent as NewNameYouWantToUse } from '@app/src/module/Component2/mycomponent.component';
add a comment |
up vote
0
down vote
import { MyComponent as NewNameYouWantToUse } from '@app/src/module/Component2/mycomponent.component';
add a comment |
up vote
0
down vote
up vote
0
down vote
import { MyComponent as NewNameYouWantToUse } from '@app/src/module/Component2/mycomponent.component';
import { MyComponent as NewNameYouWantToUse } from '@app/src/module/Component2/mycomponent.component';
answered Nov 11 at 8:53
Adrian Brand
2,48911018
2,48911018
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247132%2fangular-6-import-a-component-with-same-from-different-paths-in-a-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown