Ag-grid will not render in JHipster app (Angular 7 + Webpack 4) - jhipster

I have thoroughly followed the instructions in the following guides:
Get Started with ag-Grid in Your Angular Project
Angular Webpack 3
My app.module.ts includes:
import { AgGridModule } from 'ag-grid-angular';
...
#NgModule({
imports: [
...,
AgGridModule.withComponents([])
]
})
In vendor.css
#import "~ag-grid-community/dist/styles/ag-grid.css";
#import "~ag-grid-community/dist/styles/ag-theme-balham.css";
In the home.component.ts:
import { Component, OnInit } from '#angular/core';
import {GridOptions} from 'ag-grid-community';
#Component({
selector: 'jhi-home',
templateUrl: './home.component.html',
styleUrls: ['home.css']
})
export class HomeComponent implements OnInit {
private gridOptions: GridOptions;
public rowData: any[];
private columnDefs: any[];
constructor(
private accountService: AccountService,
private loginModalService: LoginModalService,
private eventManager: JhiEventManager
) {
this.gridOptions = <GridOptions>{
onGridReady: () => {
this.gridOptions.api.sizeColumnsToFit();
}
};
this.columnDefs = [
{headerName: 'Make', field: 'make'},
{headerName: 'Model', field: 'model'},
{headerName: 'Price', field: 'price'}
];
this.rowData = [
{make: 'Toyota', model: 'Celica', price: 35000},
{make: 'Ford', model: 'Mondeo', price: 32000},
{make: 'Porsche', model: 'Boxter', price: 72000}
];
}
ngOnInit() {
}
}
Eventually in the template I added the component:
<ag-grid-angular #agGrid style="width: 500px; height: 300px;"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="rowData">
</ag-grid-angular>
Although there are no errors at build, the grid will not render. That is the way my HTML looks after compilation:
I presume there may be an incompatibility between Angular 7/Webpack 4/the way Jhipster loads the app and ag-grid-angular.
Would you suggest any solution? Thank you!

You should import the AgGridModule on each one of your 'entities' apps modules, not on your main apps.module.ts.

Related

NestJs can't resolve service dependencies on a circular dependency

i have the problem that i have a circular dependency in my project. Unfortunately I cannot solve this with forwardRef.
The following structure:
OrderModule
OrderService
I have the following dependencies in the orderService
PriceService
CustomerService
SalePriceService
...
PriceModule
PriceService
I have the following dependencies in the priceService
OrderService
ProductService
...
I've tried all the options from the Official Documentation.
docs NestJs circular-dependency
What has to be considered here if there are more dependencies in a service?
Many thanks. Best regards.
Update:
order.module.ts
#Module({
imports: [
CustomerModule,
ProductModule,
MongooseModule.forFeature([{ name: 'Order', schema: OrderSchema }]),
forwardRef(() => PriceModule),
],
controllers: [OrderController],
providers: [OrderService],
exports: [OrderService],
})
export class OrderModule {}
order.service.ts
#Injectable()
export class OrderService extends GenericCrudService<OrderDocument> {
constructor(
#InjectModel(Order.name) readonly order: Model<OrderDocument>,
private readonly productService: ProductService,
#Inject(forwardRef(() => PriceService))
private readonly priceService: PriceService,
) {
super(order);
}
}
price.module.ts
#Module({
imports: [
CustomerModule,
SalePriceModule,
MongooseModule.forFeature([{ name: 'Price', schema: PriceSchema }]),
forwardRef(() => OrderModule),
],
controllers: [],
providers: [PriceService],
exports: [PriceService],
})
export class PriceModule {}
price.service.ts
#Injectable()
export class PriceService extends GenericCrudService<PriceDocument> {
constructor(
#InjectModel(Price.name) readonly price: Model<PriceDocument>,
private readonly customerService: CustomerService,
private readonly salePriceService: SalePriceService,
#Inject(forwardRef(() => OrderService))
private readonly orderService: OrderService,
) {
super(price);
}
}
product.module.ts
#Module({
imports: [
PriceModule,
MongooseModule.forFeature([{ name: 'Product', schema: ProductSchema }]),
],
controllers: [ProductController],
providers: [ProductService],
exports: [ProductService],
})
export class ProductModule {}
product.service.ts
#Injectable()
export class ProductService extends GenericCrudService<ProductDocument> {
constructor(
#InjectModel(Product.name) readonly product: Model<ProductDocument>,
) {
super(product);
}
}
The error I'm getting is:
The module at index [1] of the OrderModule "imports" array is undefined.
Potential causes:
- A circular dependency between modules. Use forwardRef() to avoid it. Read more: https://docs.nestjs.com/fundamentals/circular-dependency
- The module at index [1] is of type "undefined". Check your import statements and the type of the module.
Scope [AppModule -> ProductModule -> PriceModule]
Error: Nest cannot create the OrderModule instance.
The module at index [1] of the OrderModule "imports" array is undefined.
Potential causes:
- A circular dependency between modules. Use forwardRef() to avoid it. Read more: https://docs.nestjs.com/fundamentals/circular-dependency
- The module at index [1] is of type "undefined". Check your import statements and the type of the module.
Scope [AppModule -> ProductModule -> PriceModule]
So there's the obvious circular dependency that you have here: OrdersModule to PricesModule and back, that one is properly forwardReffed. However, there's another, not so obvious circular dependency too. OrdersModule to ProductsModule to PricesModule because the next import would be OrdersModule. Because of this, OrdersModule needs to forwardRef the ProductsModule and ProductsModule needs to forwardRef the PricesModule. It looks like the services themselves aren't circular, so it's just the modules that need the forward ref. Always make sure to check the entire import chain, especially when Nest is trying to report something like it did with Scope [AppModule -> ProductModule -> PriceModule].

How to change the position of the zoom control in leaflet (Angular)

I'm trying to find a way to move my control.zoom and my control.layer. I get there with the css with the :: ngdeep tag but I don't find it clean.
Here is my code:
my TS:
import { Component, OnInit } from '#angular/core';
import * as L from 'leaflet';
import {circle, icon, latLng, map, marker, polygon, tileLayer} from 'leaflet';
import {ObservatoryService} from '../../../#core/services/observatory.service';
import {Observatory} from '../../../#core/models/observatory.model';
#Component({
selector: 'ngx-observatory-labs',
templateUrl: './observatory-labs.component.html',
styleUrls: ['./observatory-labs.component.scss'],
})
export class ObservatoryLabsComponent implements OnInit {
Observ: Array<Observatory>;
ObservLayers = [];
constructor(private obsService: ObservatoryService) {
}
leafletOptions: any = {
layers: [
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
zoomControl: false,
maxZoom: 18,
attribution: '...',
id: 'mapbox.streets',
accessToken: 'your.mapbox.access.token',
}),
L.control.zoom({
position: 'bottomleft',
}),
L.control.layer-toggle({
position: 'topleft',
}),
],
zoom: 17,
center: L.latLng({lat: 43.599508, lng: 1.439671}),
};
layersControl = {
baseLayers: {
'Open Map basic': tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{maxZoom: 18, attribution: '...'}),
'Open Cycle Map': tileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png',
{maxZoom: 18, attribution: '...'}),
'Open satelit Map': tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
{maxZoom: 18, attribution: '...'}),
},
overlays: {
'Critical Zone': L.layerGroup([
circle([43.529070, 1.429942], {radius: 60, color: 'green'}).bindTooltip('<b>Hôtel :</b><br>la flannerie')]),
},
};
My Html:
<div style="height: 700px;"
leaflet
[leafletOptions]='leafletOptions'
[leafletLayersControl]='layersControl'
[leafletLayers]="ObservLayers">
</div>
I tried to move the elements in the initialization of the map but it does not work and I did not find any satisfying examples either. Would someone have the solution please.
You can do it by importing the leaflet CSS in your styles.scss:
#import '../node_modules/leaflet/dist/leaflet.css';
.leaflet-touch .leaflet-bar a {
width: 30px;
height: 30px;
line-height: 30px;
}

How can I solve this depency error in Nestjs

I can't find out, where my problem is. I get the following error:
Nest can't resolve dependencies of the BService (?, AService). Please
make sure that the argument at index [0] is available in the CModule
context.
I have 3 Modules, A, B, C.
C should be able to use services from B, and B should call services from A.
A and B have TypeOrm imports and an entity each.
Here is the code:
app.modules.ts:
#Module({
imports: [
TypeOrmModule.forRoot(),
CModule
]
})
export class AppModule {}
c.module.ts:
#Module({
imports: [BModule],
controllers: [CController],
providers: [BService]
})
export class CModule {}
b.module.ts:
#Module({
imports: [
AModule,
TypeOrmModule.forFeature([B], 'default')
],
providers: [BService],
exports: [AModule, BService]
})
b.entity.ts:
#Entity()
export class B {
#PrimaryGeneratedColumn()
id: number;
#Column()
name: string;
}
b.service.ts:
#Injectable()
export class BService {
constructor(
#InjectRepository(B, 'default')
private readonly bRepository: Repository<B>,
private readonly aService: AService
) {}
}
a.module.ts:
#Module({
imports: [
TypeOrmModule.forFeature([A], 'default')
],
providers: [AService],
exports: [AService]
})
export class AModule {}
a.entity.ts:
#Entity()
export class A {
#PrimaryGeneratedColumn()
id: number;
#Column()
name: string;
}
a.service.ts:
#Injectable()
export class AService {
constructor(
#InjectRepository(A, 'default')
private readonly aRepository: Repository<A>) {
}
}
In your CModule you do not need to define providers: [BModule] as you will overwrite the value given from BModule. As BModule already exports BService you shouldn't need to do anything other than import BModule into your CModule then you can use BService with no problems.
Side remark: is there any reason you have dependencies across your modules? Most of the time if you can keep from importing other modules if it isn't necessary it'll make a lot of your code easier to work with.

Cannot find module in Typescript

hy guys i have problem like this,
i have a app.typescript
and inside it i import
import { Component } from '#angular/core';
import {CORE_DIRECTIVES} from '#angular/common';
import { MODAL_DIRECTVES } from 'ng2-bootstrap';
#Component({
moduleId: module.id,
selector: 'my-app',
templateUrl: 'my-app.component.html',
styleUrls: ['my-app.component.css'],
directives: [MODAL_DIRECTVES]
})
export class my-appComponent {
title = 'Mp App';
}
but when i run it i got an error that say cant find module ng2-bootstrap
As per the documentation here. It appears you must import from a nested path:
import { MODAL_DIRECTIVES } from 'ng2-bootstrap/ng2-bootstrap';
or
import { MODAL_DIRECTIVES } from 'ng2-bootstrap/components/modal';

How to extend ionic2 tab component?

Getting started on Ionic2 which is based on Angular2 and I'm currently trying to extend the base tab component to add an extra input. The point is to sort a list of models into tabs by an attribute.
My class is the following:
import {Component, Directive, Host, ElementRef, Compiler, DynamicComponentLoader, AppViewManager, NgZone, Renderer} from 'angular2/angular2';
import {IonicApp, Config, Keyboard, NavController, ViewController, Tabs, Tab} from 'ionic/ionic';
#Component({
selector: 'list-tab',
inputs: [
'root',
'tabTitle',
'tabIcon'
],
host: {
'[class.show-tab]': 'isSelected',
'[attr.id]': '_panelId',
'[attr.aria-labelledby]': '_btnId',
'role': 'tabpanel'
},
template: '<template #contents></template>'
})
export class ListTab extends Tab {
constructor(
#Host() parentTabs: Tabs,
app: IonicApp,
config: Config,
keyboard: Keyboard,
elementRef: ElementRef,
compiler: Compiler,
loader: DynamicComponentLoader,
viewManager: AppViewManager,
zone: NgZone,
renderer: Renderer
) {
super(parentTabs, app, config, keyboard, elementRef, compiler, loader, viewManager, zone, renderer);
}
}
I then try using it as a normal tab :
<ion-tabs>
<list-tab *ng-for="#tab of tabs" tab-title="{{tab.title}}" tab-icon="{{tab.icon}}" [root]="tab.component"></list-tab>
</ion-tabs>
But it displays the following error :
Error: Cannot resolve all parameters for ListTab(Tabs #Host() #Host(), IonicApp, Config, ?, ElementRef, Compiler, DynamicComponentLoader, AppViewManager, NgZone, Renderer). Make sure they all have valid type or annotations.
at NoAnnotationError.BaseException [as constructor] (http://localhost:8100/build/js/app.bundle.js:26209:24)
at new NoAnnotationError (http://localhost:8100/build/js/app.bundle.js:27069:17)
at _extractToken (http://localhost:8100/build/js/app.bundle.js:26183:16)
at http://localhost:8100/build/js/app.bundle.js:26135:46
at Array.map (native)
at Array.map (http://localhost:8100/build/js/app.bundle.js:1158:15)
at _dependenciesFor (http://localhost:8100/build/js/app.bundle.js:26135:20)
at resolveFactory (http://localhost:8100/build/js/app.bundle.js:26015:25)
at Object.resolveProvider (http://localhost:8100/build/js/app.bundle.js:26039:67)
at Function.DirectiveProvider.createFromProvider (http://localhost:8100/build/js/app.bundle.js:36482:30)
I've tried different ways of getting Keyboard to import correctly as it seems it doesn't recognize it's annotation, but nothing seems to correct the error.
Is this a framework bug which wouldn't be surprising since we're in alpha, or am I doing something wrong?
Thanks
Try my code, works on 2.0.0-beta.3
import {Tab, Config} from "ionic-angular";
import {Keyboard} from "ionic-angular/util/keyboard";
import {Component, Inject, forwardRef, ElementRef, Compiler, AppViewManager, NgZone, Renderer, ViewEncapsulation} from 'angular2/core';
import {ShiftingTabs} from './tabs';
import {IonicApp} from "ionic-angular";
#Component({
selector: 'shifting-tab',
inputs: [
'root',
'tabTitle',
'tabIcon'
],
host: {
'[class.show-tab]': 'isSelected',
'[attr.id]': '_panelId',
'[attr.aria-labelledby]': '_btnId',
'role': 'tabpanel'
},
template: '<div #contents></div>',
encapsulation: ViewEncapsulation.None
})
export class ShiftingTab extends Tab {
constructor(
#Inject(forwardRef(() => ShiftingTabs)) parentTabs: ShiftingTabs,
app: IonicApp,
config: Config,
keyboard: Keyboard,
elementRef: ElementRef,
compiler: Compiler,
viewManager: AppViewManager,
zone: NgZone,
renderer: Renderer
) {
super(
parentTabs, app, config, keyboard, elementRef, compiler,
viewManager, zone, renderer
);
}
}
example of use:
<ion-tabs tabbarPlacement="top">
<shifting-tab [root]="tab1Root" tabTitle="Test1"></shifting-tab>
</ion-tabs>

Resources