I've almost caused a name collision, because I've created a class with common name Message
, which already exists in PrimeNG:
import {Message} from "primeng/primeng";
import {Message} from "./dto";
Because it is my code, I could simply rename the class to anything else (like MessageDTO
). But if this was the external class, I'd have an issue.
Is there any way to import class with alias, or any other mean to deal with name conflicts? I Java you can refer to class using fully qualified name instead of import, which looks ugly but is often unavoidable. How it looks like in Angular 2/TypeScript?
Tell Angular how to construct and bootstrap the app in the root "AppModule". An Angular module class describes how the application parts fit together. Every application has at least one Angular module, the root module that you bootstrap to launch the application.
BrowserModule provides services that are essential to launch and run a browser application. BrowserModule also re-exports CommonModule from @angular/common , which means that components in the AppModule also have access to the Angular directives every application needs, such as NgIf and NgFor .
Declarables allow the angular compiler to know which module will actually contain the component, directive or pipe. As the compiler generates the factories that make the views, it will integrate those components with the module they were declared, and only refer to them in any other module that might be using them.
NgModules consolidate components, directives, and pipes into cohesive blocks of functionality, each focused on a feature area, application business domain, workflow, or common collection of utilities. Modules can also add services to the application.
As per TypeScript
import document imports can also be renamed same as below :
import { Message } from "primeng/primeng";
import { Message as MessageDTO } from "./dto";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With