angular-module

Angular - Using a component across multiple modules

混江龙づ霸主 提交于 2019-12-10 01:50:29
问题 What I'm using Angular What I'm trying to do I have a loading component I want to reuse across multiple modules What I've done I've created a new module called 'loading-overlay' Inside this module I export the overlay component I add this module to app.module When adding the component to multiple modules I receive the following error: Type LoadingOverlayComponent is part of the declarations of 2 modules: LoadingOverlayModule and ProjectsModule! Please consider moving LoadingOverlayComponent

Use component from AppModule in a child module in Angular X (X stands for 2+)

时光总嘲笑我的痴心妄想 提交于 2019-12-09 10:53:44
问题 I have created a small component ( LoadingComponent ) in the root of my application and declared it (obviously) in my AppModule . This component is used when my application is loading and should show some fancy loading animations. Now I want to use it in a child module when I save something. But I am always getting errors when I want to use this component in another module. I exported the LoadingComponent in my AppModule: import { ButtonsModule } from './buttons/buttons.module'; import {

Dynamically load Angular 4 template using existing component and module

丶灬走出姿态 提交于 2019-12-08 05:57:53
问题 I am attempting to load an HTML template received from the backend. This template includes custom pipes and should be populated with data that is received from a different web service. Here is an example of how it is currently set up. -app -/person --person.module.ts --person.service.ts --/person-info ---person-info.component.ts Ideally, I would like to receive the template and set it up within the person-info.component.ts since I have all of the necessary code for that HTML in that component

Error importing external angular module at runtime

早过忘川 提交于 2019-12-07 12:16:27
问题 I have been trying to dynamically load an external angular module (AppA) into another angular application (AppB) at runtime. AppA is created with angular-cli, compiled with ngc and packaged with rollupjs. Perfect. I have two cases: AppB completely configured with SystemJS. It can load AppA using System.import instruction without problems. AppB created with angular-cli. There has not been a way to make it work. In the second case, I have two subcases: I tried to import on this way but it does

Angular Service singleton constructor called multiple times

我的未来我决定 提交于 2019-12-07 02:28:39
问题 I am trying to use an app-wide service (UserService) that stores authenticated user details. I have set up some routes but found that UserService is instantiated per route. I want them to share the same UserService. I have created a CoreModule containing TestService as provider and imported it into AppModule. core.module.ts: import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { TestService } from '../test.service'; @NgModule({ imports: [

Angular Library Modules export components, services and others from module

喜夏-厌秋 提交于 2019-12-05 21:38:28
I have created an Angular Library. In my Library I would it like it to be clean by having feature modules inside them: Example: Library NavigationModule NavigationSideBarComponent NavigationTopComponent Navigation Service etc GraphModule BarGraphComponent PieGraphComponent My Navigation Module currently looks like this: @NgModule({ declarations: [ NavigationSidebarComponent ], imports: [ CommonModule, MatSidenavModule ], exports: [ NavigationSidebarComponent ] }) export class NavigationModule { } My Library Module currently looks like this: @NgModule({ declarations: [LibraryComponent], imports

Error importing external angular module at runtime

荒凉一梦 提交于 2019-12-05 21:33:29
I have been trying to dynamically load an external angular module (AppA) into another angular application (AppB) at runtime. AppA is created with angular-cli, compiled with ngc and packaged with rollupjs. Perfect. I have two cases: AppB completely configured with SystemJS. It can load AppA using System.import instruction without problems. AppB created with angular-cli. There has not been a way to make it work. In the second case, I have two subcases: I tried to import on this way but it does not let compile because it does not find the module in its own application. declare var System; System

Angular Service singleton constructor called multiple times

Deadly 提交于 2019-12-05 07:10:43
I am trying to use an app-wide service (UserService) that stores authenticated user details. I have set up some routes but found that UserService is instantiated per route. I want them to share the same UserService. I have created a CoreModule containing TestService as provider and imported it into AppModule. core.module.ts: import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { TestService } from '../test.service'; @NgModule({ imports: [ CommonModule ], declarations: [], providers: [ TestService ] }) export class CoreModule { } test.service.ts:

How should I include model classes in an Angular module?

时光总嘲笑我的痴心妄想 提交于 2019-12-05 07:03:27
I've a few classes I want to be just a plain bean/DTO class, they aren't display @component classes, they're not @Pipe classes nor should they be @Directive (at least I don't think it should be!). I want to be able to bundle them into a module (they will be used across other modules), but despite several incantations I keep getting errors like this: When I startup my Angular app (ng serve) it compiles ok, but in the browser (Chrome) console I get an error.... Uncaught Error: Unexpected value 'Accreditation' declared by the module 'ServiceModule'. Please add a @Pipe/@Directive/@Component

How does one go about creating an Angular library wrapper for an existing Javascript library?

夙愿已清 提交于 2019-12-04 23:48:45
Suppose there exists a Javascript library written in plain Javascript and commonly used on vanilla, non-frameworked websites. How does one go about creating an Angular library that can easily be npm install ed that would make the library seamless to use in an Angular app? I cannot find any good demonstrations of this process in the Angular docs or on the wider web. Just for instance, there is a fantastic Javascript library called p5.js , which is not straightforward to use with Angular. How would one go about creating an Angular module that you can simply import into your own Angular module