angular-library

Add Angular Material to a custom library

纵饮孤独 提交于 2020-06-22 08:04:11
问题 I want to write my own library and reuse it in other projects, so I created a new app and generated a library there: ng new lib-collection cd lib-collection ng g library first-lib --prefix va How to add Angular Material to my library? I wanted to use something like this: ng add @angular/material --project=first-lib But I got an error: Could not find the project main file inside of the workspace config (projects/first-lib/src) . What's wrong? 回答1: You don't need to add it there. You need to

Angular shared assets within multiple applications

一笑奈何 提交于 2020-06-01 06:39:06
问题 I am working on multiple small apps, which will share common and shared modules, and assets. The part about how to create project structure was answered here: https://stackoverflow.com/a/61254557/1351452 My project folders structure is as follow: -root --projects ---app1 ---app2 ---library I want to share assets (images and fonts) between apps and library (for example I have header component with logo) I want to have one place for all the css (SCSS). Some compoents from shared library have

Class is not an Angular module - only in IntelliJ/Webstorm when importing locally build Angular library

六眼飞鱼酱① 提交于 2020-05-15 09:02:02
问题 I am trying to use Angular module implemented in a library (project) which exists in a separate Angular application. In IntelliJ I am getting an error Class MyModule is not an Angular module and all the library seems to not be recognized in IntelliJ while I can successfully run ng build for this project. Whats even more weird is that I have actually two Angular libraries existing in the other Angular app and I can use modules from the other library without issues. I've visited other similarly

Angular 6 / declare path for library in tsconfig.lib.json

笑着哭i 提交于 2020-05-15 02:16:08
问题 I'm trying to configure the paths for an Angular 6 library (I have successfully configured the paths for a previous Angular project) Here is what is working for my previous app in the tsconfig.json file: "compilerOptions": { [...] "baseUrl": "src", "paths": { "@class/*": [ "app/class/*" ], "@services/*": [ "app/services/*" ], "@views/*": [ "app/views/*" ] } } and then use it like for example: Import { Item } form '@class/item'; In my new app I'm trying the same way in the tsconfig.**lib**

How to create an angular library that intercepts http requests made from my app

情到浓时终转凉″ 提交于 2020-04-13 16:51:27
问题 I am trying to create an angular library that intercepts http requests from the app it is imported in. The issue is that the interceptor doesn't work if it is imported from the library but if I move it inside my app it is working. the interceptor code from my library looks like this: import { Injectable } from '@angular/core'; import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http'; import { Observable, throwError} from 'rxjs'; import { catchError } from

Library build fails with Angular 9

て烟熏妆下的殇ゞ 提交于 2020-04-13 06:34:13
问题 I am trying to migrate this library https://github.com/flauc/angular2-notifications from Angular 2+ to Angular 9. The original error was about the ModuleWithProviders that has become a generic type, so I fixed it. I also had an error described here https://github.com/angular/angular/issues/32352 which i fixed with require('@angular/compiler-cli'); and now I'm facing another error: ../node_modules/@angular/common/common.d.ts:115:22 - error NG6002: Appears in the NgModule.imports of

Angular Module vs. Library

人走茶凉 提交于 2020-01-23 12:06:32
问题 So great, the Angular has released version 6 and the CLI provides an option to generate libraries - something that they call a "highly anticipated feature". Now, coming from a business perspective, I am wondering: why you would actually need this, why inside of an existing project and not a separate which you can install as usual via npm... and if you want this inside your project, why not use a module for that. So I get it, publish something on npmjs and hope the whole world and future

Load one module from Angular Library Instead of loading the whole library

核能气质少年 提交于 2020-01-23 10:11:03
问题 I have an angular library that has been generated with the following command: ng generate library cac-models In this library, I have two modules named Admin and Client Module.When I'd like to use Admin module I have to load it like the following command and then import it: import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import {

Angular Library Route Module does not work when imported in application

孤街醉人 提交于 2020-01-21 12:42:35
问题 I need a help about an issue that I cannot solve. I'm studying angular 7 library in order to add modularization to my application but module routes defined in library seems not work when install it in a application. I have created project to github to reproduce problem: Library test foo-lib External Applicationfoo-tester In each ReadMe file I have described how to reproduce this issue. I have created an example library (foo-lib) with its routing module with child route defined, then I had

Angular Library Route Module does not work when imported in application

笑着哭i 提交于 2020-01-21 12:42:00
问题 I need a help about an issue that I cannot solve. I'm studying angular 7 library in order to add modularization to my application but module routes defined in library seems not work when install it in a application. I have created project to github to reproduce problem: Library test foo-lib External Applicationfoo-tester In each ReadMe file I have described how to reproduce this issue. I have created an example library (foo-lib) with its routing module with child route defined, then I had