Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/app1/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import { AppRootComponent } from './root/root.component';
import { DemoCommonModule } from '@demo/common';
import { NgxPlanetModule } from 'ngx-planet';
import { UserModule } from './user/user.module';
import { ProjectsComponent } from './projects/projects.component';

@NgModule({
declarations: [AppComponent, AppRootComponent, DashboardComponent],
declarations: [AppComponent, AppRootComponent, DashboardComponent, ProjectsComponent],
imports: [
BrowserModule,
RouterModule.forRoot(routers),
Expand Down
5 changes: 5 additions & 0 deletions examples/app1/src/app/app.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DashboardComponent } from './dashboard/dashboard.component';
import { Route } from '@angular/router';
import { AppRootComponent } from './root/root.component';
import { EmptyComponent } from 'ngx-planet';
import { ProjectsComponent } from './projects/projects.component';

export const routers: Route[] = [
{
Expand All @@ -20,6 +21,10 @@ export const routers: Route[] = [
{
path: 'users',
loadChildren: () => import('./user/user.module').then(mod => mod.UserModule)
},
{
path: 'projects',
component: ProjectsComponent
}
// {
// path: 'users',
Expand Down
4 changes: 2 additions & 2 deletions examples/app1/src/app/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ <h5 class="red">count: {{ counter.count }}</h5>

<section-card class="mt-4" title="Render app2's component">
<div class="btn-pair">
<button thyButton="primary-square" (click)="openApp2Component()">Open App2 Project list</button>
<button thyButton="primary-square" (click)="disposeApp2Component()">Dispose App2 Project list</button>
<button thyButton="primary-square" (click)="openApp2Component()">Open App2 Projects</button>
<button thyButton="primary-square" (click)="disposeApp2Component()">Dispose App2 Projects</button>
</div>
<div #container></div>
</section-card>
18 changes: 12 additions & 6 deletions examples/app1/src/app/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Inject, ViewChild, ElementRef } from '@angular/core';
import { Component, Inject, ViewChild, ElementRef, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { CounterService } from '../counter.service';
import { AppRootContext } from '@demo/common';
Expand All @@ -9,7 +9,7 @@ import { ThyDialog } from 'ngx-tethys';
selector: 'app-dashboard',
templateUrl: './dashboard.component.html'
})
export class DashboardComponent {
export class DashboardComponent implements OnInit {
@ViewChild('container', { static: true }) containerElementRef: ElementRef<HTMLDivElement>;

private componentRef: PlanetComponentRef;
Expand All @@ -24,15 +24,21 @@ export class DashboardComponent {
private planetComponentLoader: PlanetComponentLoader
) {}

ngOnInit() {}

openADetail() {
this.globalEventDispatcher.dispatch('openADetail');
}

openApp2Component() {
this.componentRef = this.planetComponentLoader.load('app2', 'project1', {
container: this.containerElementRef,
initialState: {}
});
this.planetComponentLoader
.load('app2', 'project1', {
container: this.containerElementRef,
initialState: {}
})
.subscribe(componentRef => {
this.componentRef = componentRef;
});
}

disposeApp2Component() {
Expand Down
32 changes: 32 additions & 0 deletions examples/app1/src/app/projects/projects.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { PlanetComponentLoader } from 'ngx-planet';

@Component({
selector: 'app-projects',
template: `
<section-card class="mt-2" title="App2's projects component">
<thy-loading [thyDone]="loadingDone"></thy-loading>
<div #container></div>
</section-card>
`
})
export class ProjectsComponent implements OnInit {
@ViewChild('container', { static: true }) elementRef: ElementRef<HTMLDivElement>;

loadingDone = false;

constructor(private planetComponentLoader: PlanetComponentLoader) {}

ngOnInit() {
this.planetComponentLoader
.load('app2', 'project1', {
container: this.elementRef
})
.subscribe(componentRef => {
this.loadingDone = true;
componentRef.componentInstance.click.subscribe(() => {
console.log('project item clicked');
});
});
}
}
1 change: 1 addition & 0 deletions examples/app1/src/app/root/root.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<thy-menu>
<a thyMenuItem [routerLink]="['/app1/dashboard']" routerLinkActive="active">App1 Dashboard</a>
<a thyMenuItem [routerLink]="['/app1/users']" routerLinkActive="active">App1 Users</a>
<a thyMenuItem [routerLink]="['/app1/projects']" routerLinkActive="active">App2 Projects</a>
</thy-menu>
</div>
</thy-sidebar>
Expand Down
3 changes: 1 addition & 2 deletions examples/app2/src/app/projects/project-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ export class ProjectListComponent implements OnInit, DoCheck {

openDetail(event: ThyGridRowEvent) {
this.router.navigateByUrl(`/app2/projects/${event.row.id}`);
this.click.emit();
// this.dialog.open(ProjectDetailComponent, {
// hasBackdrop: true,
// backdropClosable: true,
// closeOnNavigation: true
// });

// this.click.emit();
}

ngDoCheck() {
Expand Down
Loading