This is my app.routing.module.ts code :
import { NgModule } from '#angular/core';
import { Routes, RouterModule } from '#angular/router';
import { PageLoginComponent } from './components/page-login/page-login.component';
import { LoginGuard } from './login.guard';
import { DashboardComponent } from './components/dashboard/dashboard.component';
import { CreatedDatasourcesComponent } from './components/created-datasources/created-datasources.component';
import { RegisterComponent } from './components/register/register.component';
const routes: Routes = [
{ path: '', component: PageLoginComponent },
{ path: 'login', component: PageLoginComponent },
{
path: 'signup',
component: RegisterComponent
},
{
path: 'dashboard',
canActivate: [LoginGuard],
children: [
{ path: '', component: DashboardComponent }
]
},
{ path: 'datasources', component: CreatedDatasourcesComponent },
{ path: 'datasources/:status', component: CreatedDatasourcesComponent },
];
#NgModule({
imports: [RouterModule.forRoot(routes, {useHash: true})],
exports: [RouterModule]
})
export class AppRoutingModule { }
This is app.module.ts code :
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import { HttpModule } from '#angular/http';
import { HttpClientModule, HTTP_INTERCEPTORS } from '#angular/common/http';
import { FormsModule } from '#angular/forms';
import { BrowserAnimationsModule } from '#angular/platform-browser/animations';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { PageLoginComponent } from './components/page-login/page-login.component';
import { LoginService } from './services/login.service';
import { LoginGuard } from './login.guard';
import { CustomInterceptor } from './custom-interceptor.service';
import { GetsrcdestService } from './services/getsrcdest.service';
import { DashboardComponent } from './components/dashboard/dashboard.component';
import { DatasourcesComponent } from './components/datasources/datasources.component';
//import { MatFormFieldModule } from '#angular/material/form-field';
import { ConnectionsContainerComponent } from './components/connections/connections-container/connections-container.component';
import { ConnectionsSelectorComponent } from './components/connections/connections-selector/connections-selector.component';
import { ConnectionsSearchComponent } from './components/connections/connections-search/connections-search.component';
import { ConnectionsListComponent } from './components/connections/connections-list/connections-list.component';
import { BackdropComponent } from './components/backdrop/backdrop.component';
import { ConnectionsSourceValidatorComponent } from './components/connections/connections-source-validator/connections-source-validator.component';
import { ConnectionsDestinationValidatorComponent } from './components/connections/connections-destination-validator/connections-destination-validator.component';
import { IsvalidService } from './services/isvalid.service';
import { ConnectionsDestinationFormComponent } from './components/connections/connections-destination-form/connections-destination-form.component';
import { ConnectionsFilterEndpointsComponent } from './components/connections/connections-filter-endpoints/connections-filter-endpoints.component';
import { FetchdbsService } from './services/fetchdbs.service';
import { ValidateService } from './services/validate.service';
import { ConnectionsSchedulerComponent } from './components/connections/connections-scheduler/connections-scheduler.component';
import { NavbarComponent } from './components/navbar/navbar.component';
import { ConnectionsStepperComponent } from './components/connections/connections-stepper/connections-stepper.component';
import { NgbModule, NgbDropdown } from '#ng-bootstrap/ng-bootstrap';
import { MatSidenavModule } from '#angular/material/sidenav';
import { CreatedDatasourcesComponent } from './components/created-datasources/created-datasources.component';
import { MatExpansionModule } from '#angular/material/expansion';
import { MatTableModule } from '#angular/material';
import { ChartsModule } from 'ng2-charts';
import { SidenavComponent } from './components/sidenav/sidenav.component';
import { DashboardDataService } from './dashboard-data.service';
import { LandingPageComponent } from './components/landing-page/landing-page.component';
import{FooterComponent} from './components/footer/footer.component';
import{RegisterComponent} from './components/register/register.component';
import { AlertService } from './services/alert.service';
import { SignupService } from './services/signup.service';
import{ReactiveFormsModule} from '#angular/forms'
#NgModule({
declarations: [
AppComponent,
PageLoginComponent,
DashboardComponent,
DatasourcesComponent,
ConnectionsContainerComponent,
ConnectionsSelectorComponent,
ConnectionsSearchComponent,
ConnectionsListComponent,
BackdropComponent,
ConnectionsSourceValidatorComponent,
ConnectionsDestinationValidatorComponent,
ConnectionsDestinationFormComponent,
ConnectionsFilterEndpointsComponent,
ConnectionsSchedulerComponent,
NavbarComponent,
ConnectionsStepperComponent,
CreatedDatasourcesComponent,
SidenavComponent,
LandingPageComponent,
FooterComponent,
RegisterComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
FormsModule,
HttpModule,
HttpClientModule,
NgbModule.forRoot(),
MatSidenavModule,
MatExpansionModule,
MatTableModule,
ChartsModule,
ReactiveFormsModule
],
providers: [
LoginService,
GetsrcdestService,
IsvalidService,
FetchdbsService,
ValidateService,
DashboardDataService,
AlertService,
SignupService,
{ provide: HTTP_INTERCEPTORS, useClass: CustomInterceptor, multi: true },
LoginGuard
],
bootstrap: [LandingPageComponent]
})
export class AppModule { }
and following is the line of code where i am calling the component
<li class="nav-item active">
<a routerLink="signup" class="nav-link">SignUp</a>
</li>
Have imported new component everywhere, in app.module.ts as well in routing file still it is not working, not showing any console error.
While clicking on the link it is showing in url /signup but component is not showing up.
How to solve this issue and how to give link of following code to work?
Related
i'm trying some css test on my project, but one of my component don't want to show his css.
This is my Angular structure :
my app.component.html
<div id="nav-bar">
<div id="nav-bar-content">
<div id="nav-bar-left">
<div>Pangolin</div>
</div>
<div id="nav-bar-right">
<div>Register</div>
</div>
</div></div>
<router-outlet></router-outlet>
my app.component.css
#nav-bar {
border: solide 5px red;
}
my app.component.ts
import { Component } from '#angular/core';
#Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'socialnetworkapp';
}
and this is what i have in my browser :
and this is my app.module.ts
// built in
import { NgModule } from '#angular/core';
import { BrowserModule } from '#angular/platform-browser';
import { FormsModule } from '#angular/forms';
import { HttpClientModule } from '#angular/common/http';
import {MatButtonModule} from '#angular/material/button';
//component import
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { UserComponent } from './components/user/user.component';
import { LoginComponent } from './components/login/login.component';
import { AccountComponent } from './components/account/account.component';
import { PageOneComponent } from './components/page-one/page-one.component';
import { navbarComponent } from './components/navbar/navbar.component';
import { SignUpComponent } from './components/sign-up/sign-up.component';
import { BrowserAnimationsModule } from '#angular/platform-browser/animations';
#NgModule({
declarations: [
AppComponent,
UserComponent,
LoginComponent,
AccountComponent,
PageOneComponent,
navbarComponent,
SignUpComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
HttpClientModule,
MatButtonModule,
BrowserAnimationsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
My /src/app/components/page-one module works perfectly. Is it some children, parents issue there ? I'm new on Angular
Your CSS is incorrect, solide should be solid:
#nav-bar {
border: solid 5px red;
}
See MDN border-style for a full list of valid border styles.
I don't really know how to fix this problem, usually we have this problem because "CommunModule" or "BrowserModule" are not imported, but in my case everything is already imported...
So if you see something I forgot, please tell me.
btw I'm using Angular 10
Here is the way I import in app.module.ts
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import { CommonModule } from '#angular/common';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '#angular/platform-browser/animations';
import { HomeComponent } from './Home/home.component';
import { MatIconModule} from '#angular/material/icon';
import { MatMenuModule } from '#angular/material/menu';
import { MatTabsModule } from '#angular/material/tabs';
import { MatCarouselModule } from '#ngmodule/material-carousel';
import { MatCardModule } from '#angular/material/card';
import { MatButtonModule } from '#angular/material/button';
import { MatGridListModule } from '#angular/material/grid-list';
import { MatDialogModule } from '#angular/material/dialog';
import { HomeDialogComponent } from './home-dialog/home-dialog.component';
import { MatStepperModule } from '#angular/material/stepper';
#NgModule({
declarations: [
AppComponent,
HomeComponent,
HomeDialogComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MatIconModule,
MatMenuModule,
MatTabsModule,
MatCarouselModule,
MatCardModule,
MatButtonModule,
MatGridListModule,
MatDialogModule,
MatStepperModule,
CommonModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
HTML
<mat-card-actions *ngif = "tile.seeMore === true">
<button mat-button (click)="openDialog()">See more</button>
</mat-card-actions>
I'm using this tutorial to display simple dialog.
The problem is that the dialog displays empty and the console show no error.
Even when i try to change parts from my dialog.component.html, or from dress-form.ts, nothing changes.
Here is my component from where i open the dialog (dress-form.ts):
import { MatDialog } from '#angular/material/dialog';
import { DialogComponent } from 'src/app/dialog/dialog.component';
#Component({
selector: 'dress-form',
styleUrls: ['dress-form.css'],
templateUrl: 'dress-form.component.html',
})
export class DressFormComponent {
constructor(public dialog: MatDialog) { }
openDeleteDialog() {
const dialogRef = this.dialog.open(DialogComponent, {
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
})
}
}
that is my dialog component (dialog.component.ts):
import { Component, OnInit, Inject } from '#angular/core';
import { MatDialogRef } from '#angular/material/dialog';
import { MAT_DIALOG_DATA } from '#angular/material/dialog';
#Component({
selector: 'dialog',
styleUrls: ['dialog.css'],
templateUrl: 'dialog.component.html',
})
export class DialogComponent implements OnInit {
constructor(public dialogRef: MatDialogRef<DialogComponent>,
#Inject(MAT_DIALOG_DATA) public data: any) { }
ngOnInit() {
}
okToDelete() {
this.dialogRef.close();
console.log("this item will be deleted!")
}
}
dialog.component.html:
<html lang="he" dir="rtl"></html>
<h2 mat-dialogititle>tile</h2>
<mat-dialog-content>
<p>this is the content</p>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-button mat-dialog-close>cancel</button>
<button mat-button (click)="okToDelete()">delete</button>
</mat-dialog-actions>
app.module.ts:
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import { AppRoutingModule, RoutingComponent } from './app-routing.module';
import { AppComponent } from './app.component';
import { DressesComponent } from './dresses/dresses.component';
import { HttpClientModule } from '#angular/common/http';
import { DressesService } from './services/dresses.service';
import { BrowserAnimationsModule } from '#angular/platform-browser/animations';
import { MatTableModule } from '#angular/material/table';
import { MatSelectModule } from '#angular/material/select';
import { MatDialogModule } from '#angular/material/dialog';
import { MatInputModule } from '#angular/material/input';
import { LoadingSpinnerComponent } from './ui/loading-spinner/loading-spinner.component';
import { MatToolbarModule } from '#angular/material/toolbar';
import { MatIconModule } from '#angular/material/icon';
import { ButtonToggle } from './button-toggle/button-toggle.component';
import { MatButtonToggleModule } from '#angular/material/button-toggle';
import { Sidenav } from './side-nav/side-nav.component';
import { MatSidenavModule } from '#angular/material/sidenav';
import { StockService } from './services/stock.service';
import { MatPaginatorModule } from '#angular/material/paginator';
import { MatSortModule } from '#angular/material/sort'
import { FormsModule, ReactiveFormsModule } from '#angular/forms';
import { MatCardModule } from '#angular/material/card';
import { TestComponent } from './test/test.component'
import { MatDividerModule } from '#angular/material/divider';
import { MatButtonModule } from '#angular/material/button';
import { UpdateStockTableComponent } from './dresses/dress-form/update-stock-table/update-stock-table.component'
import { SearchTableService } from './services/search-table.service';
import { MatSlideToggleModule } from '#angular/material/slide-toggle'
import { MatTabsModule } from '#angular/material/tabs';
import { DressDetailsComponent } from './stock/stock-form/dress-detils/dress-details.component';
import { FixesComponent } from './stock/stock-form/fixes/fixes.component';
import { DialogComponent } from './dialog/dialog.component';
#NgModule({
declarations: [
AppComponent,
DressesComponent,
LoadingSpinnerComponent,
ButtonToggle,
Sidenav,
RoutingComponent,
TestComponent,
UpdateStockTableComponent,
DressDetailsComponent,
FixesComponent,
DialogComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
BrowserAnimationsModule,
MatTableModule,
MatSelectModule,
MatDialogModule,
MatInputModule,
MatToolbarModule,
MatIconModule,
MatButtonToggleModule,
MatSidenavModule,
MatPaginatorModule,
MatSortModule,
BrowserAnimationsModule,
FormsModule,
ReactiveFormsModule,
MatCardModule,
MatDividerModule,
MatButtonModule,
MatSlideToggleModule,
MatTabsModule
],
entryComponents: [DialogComponent],
providers: [DressesService, StockService, SearchTableService],
bootstrap: [AppComponent]
})
export class AppModule { }
Had the exact same issue and couldn't find a solution anywhere. Like you I had my selector name as 'dialog', after changing this to 'app-dialog' it worked as expected.
According do your code the problem should be in the html of dialog component
<html lang="he" dir="rtl"></html> // remove this line no nee for this one
// <h2 mat-dialogititle>tile</h2>
// Change the abouve line to this line
<h2 mat-dialog-title>Install Angular</h2>
<mat-dialog-content>
<p>this is the content</p>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-button mat-dialog-close>cancel</button>
<button mat-button (click)="okToDelete()">delete</button>
</mat-dialog-actions>
Read more about rtl support in angular in docs https://material.angular.io/cdk/bidi/overview
I need to implement a customized tooltip for ag-Grid in angular 6.
Following is my code :
app.component.ts
import { Component, OnInit } from '#angular/core';
import { MyTooltipComponent } from '../my-tooltip/my-tooltip.component';
#Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
private frameworkComponents = {};
constructor() {
this.frameworkComponents = { myTooltipComponent: MyTooltipComponent };
}
aggridConfig0: any = {
rowData: [],
columnDefs: [],
defaultColDef: {
filter: true,
sortable: true,
resizable: false,
editable: false,
enableRowGroup: false,
tooltipComponent: "myTooltipComponent"
},
cubeXCreateAgGridColumn: (data) => {
let temp = [];
data.forEach((val, key) => {
if (key == 0) {
Object.keys(val).forEach((name) => {
temp.push({
headerName: name,
field: name,
tooltipField: tooltipName
})
})
}
});
return temp;
}
}
private gridApi0;
private gridColumnApi0;
agGrid;
onGridReady0(params) {
this.agGrid = [
{
"header1": "abc",
"header2": "efg"
},
{
"header1": "def",
"header2": "xyz"
}
];
this.gridApi0 = params.api;
this.gridColumnApi0 = params.columnApi;
this.aggridConfig0.rowData = this.agGrid;
this.gridApi0.setColumnDefs(this.aggridConfig0.cubeXCreateAgGridColumn(this.aggridConfig0.rowData));
}
}
app.component.html
<ag-grid-angular class="ag-theme-balham base-padding" style="height: 500px"
[rowData]="aggridConfig0.rowData"
[columnDefs]="aggridConfig0.columnDefs"
[defaultColDef]="aggridConfig0.defaultColDef"
[animateRows]="true"
[suppressDragLeaveHidesColumns]="true"
(gridReady)="onGridReady0($event)"
[frameworkComponents]="frameworkComponents">
</ag-grid-angular>
my-tooltip-component.ts
import {Component, ViewEncapsulation} from '#angular/core';
import {ITooltipAngularComp} from "#ag-grid-community/angular";
#Component({
selector: 'my-tooltip-component',
template: `
<div class="custom-tooltip">
<p><span>Header 1 : {{data.header1}}</span></p>
<p><span>Header 2 : {{data.header2}}</span></p>
</div>`,
styles: [
`
:host {
position: absolute;
width: 150px;
height: 70px;
border: 1px solid cornflowerblue;
overflow: hidden;
pointer-events: none;
transition: opacity 1s;
}
:host.ag-tooltip-hiding {
opacity: 0;
}
.custom-tooltip p {
margin: 5px;
white-space: nowrap;
}
.custom-tooltip p:first-of-type {
font-weight: bold;
}
`
]
})
export class MyTooltipComponent implements ITooltipAngularComp {
private params: any;
private data: any;
agInit(params): void {
this.params = params;
console.log("params here not printing............",params)
this.data = params.api.getDisplayedRowAtIndex(params.rowIndex).data;
this.data.color = this.params.color || 'white';
}
}
app.module.ts
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import { BrowserAnimationsModule } from '#angular/platform-browser/animations';
import { AgGridModule } from 'ag-grid-angular';
import 'ag-grid-enterprise';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing/app-routing.module';
import { MyTooltipComponent } from './component/my-tooltip/my-tooltip.component';
#NgModule({
declarations: [
AppComponent, MyTooltipComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
AgGridModule.withComponents([MyTooltipComponent])
],
providers: [ ],
bootstrap: [AppComponent]
})
export class AppModule { }
Please find the stackblitz url here :
https://stackblitz.com/edit/my-tooltip-app
I am not able to show the customized data from my-tooltip.component.ts to the header1 column tooltip.
I have referred - https://www.ag-grid.com/javascript-grid-tooltip-component/
Please help me out. Thanks in advance
The issue is resolved now.
There was an issue with the AgGrdModule that I imported. Which was previously imported from ag-grid-angular library.
I changed it to #ag-grid-community/angular
In my app.module.ts
import { AgGridModule } from "#ag-grid-community/angular";
Thanks everyone..!!
I am doing project in angular6. I have created header and footer component.
And when I am using selector <app-header> and <app-footer> in app.component.html it will work fine. But If I will use this selectors in other component it won't show header and footer. I have included this components in app.module.ts file.Can anyone please give any suggestion to fix this problem.
login.component.html
<app-header></header>
<app-footer></app-footer>
I need to display header and footer in login page. But it is not working.
app.module.ts
import { BrowserModule } from '#angular/platform-browser';
import { NgModule } from '#angular/core';
import { AppRoutingModule } from './app-routing.module';
import { CustomMaterialModule } from './material.module';
import {FormsModule, ReactiveFormsModule} from '#angular/forms';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { ContactUsComponent } from './contact-us/contact-us.component';
import { AboutUsComponent } from './about-us/about-us.component';
import { LoginComponent } from './login/login.component';
import { UserComponent } from './user/user.component';
import { BrowserAnimationsModule } from '#angular/platform-browser/animations';
import { DashboardComponent } from './dashboard/dashboard.component';
import { NotificationComponent } from './notification/notification.component';
import { SendMessageComponent } from './send-message/send-message.component';
import { DashboardRoutingModule } from './dashboard/dashboard-routing.module';
import { NotesComponent } from './notes/notes.component';
import { PopupComponent } from './popup/popup.component';
import { MyDialogComponent } from './my-dialog/my-dialog.component';
import { MatDialogModule,MatButtonModule, MatToolbarModule, MatGridListModule,MatCardModule,MatSidenavModule, MatIconModule, MatListModule } from '#angular/material';
import {MatSelectModule} from '#angular/material/select';
import { LogoutComponent } from './logout/logout.component';
import { MainNavComponent } from './main-nav/main-nav.component';
import { LayoutModule } from '#angular/cdk/layout';
import { FooterComponent } from './footer/footer.component';
import { HeaderComponent } from './header/header.component';
#NgModule({
declarations: [
AppComponent,
HomeComponent,
ContactUsComponent,
AboutUsComponent,
LoginComponent,
UserComponent,
DashboardComponent,
NotificationComponent,
SendMessageComponent,
NotesComponent,
PopupComponent,
MyDialogComponent,
LogoutComponent,
MainNavComponent,
FooterComponent,
HeaderComponent
],
imports: [
BrowserModule,
AppRoutingModule,
CustomMaterialModule,
FormsModule,
BrowserAnimationsModule,
DashboardRoutingModule,
MatDialogModule,
MatButtonModule,
ReactiveFormsModule,
MatSelectModule,
LayoutModule,
MatToolbarModule,
MatSidenavModule,
MatIconModule,
MatListModule,
MatCardModule,
MatGridListModule
],
entryComponents: [
MyDialogComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Make use of Angular Routing for reusing common components like header and footer which are common layout in web application.
Please refer:- https://blog.angularindepth.com/angular-routing-reusing-common-layout-for-pages-from-different-modules-440a23f86b57