-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from worktile/why520crazy/switch-sub-app-flicker
portal route change out ngZone when sub app route trigger change fix flicker when switch router in sub app
- Loading branch information
Showing
22 changed files
with
234 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
<h4>This is app2's dashboard</h4> | ||
<thy-content> | ||
<h4>This is app2's dashboard</h4> | ||
|
||
<section-card class="mt-3" title="Links to about"> | ||
<div><a href="javascript:;" (click)="toAbout()">About</a></div> | ||
<a><a href="javascript:;" [routerLink]="['/about']">About use routerLink</a></a> | ||
</section-card> | ||
<section-card class="mt-3" title="Links to about"> | ||
<div><a href="javascript:;" (click)="toAbout()">About</a></div> | ||
<a><a href="javascript:;" [routerLink]="['/about']">About use routerLink</a></a> | ||
</section-card> | ||
|
||
<section-card class="mt-4" title="Open app1's user detail"> | ||
<button thyButton="outline-primary-square" (click)="openApp1UserDetail()">Open user detail (id: 1)</button> | ||
</section-card> | ||
<section-card class="mt-4" title="Open app1's user detail"> | ||
<button thyButton="outline-primary-square" (click)="openApp1UserDetail()">Open user detail (id: 1)</button> | ||
</section-card> | ||
</thy-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 16 additions & 4 deletions
20
examples/app2/src/app/projects/detail/detail.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
<thy-dialog-header thyTitle="项目详情"> </thy-dialog-header> | ||
<div class="dialog-body"> | ||
This is project detail! | ||
</div> | ||
<thy-header thyHasBorder="true"> | ||
<ng-template #headerTitle> | ||
<!-- <thy-icon class="prefix-icon" thyIconName="house-square" thyIconType="fill"></thy-icon> --> | ||
<!-- <a href="javascript:;" class="title-name">Project Detail {{ projectId }} </a> --> | ||
<span>Project Detail {{ projectId }}</span> | ||
</ng-template> | ||
<ng-template #headerContent> | ||
<thy-nav thyType="primary" thyHorizontal="center"> | ||
<a href="javascript:;" thyNavLink thyNavLinkActive="true">Tasks</a> | ||
<a href="javascript:;" thyNavLink>Defects</a> | ||
</thy-nav> | ||
</ng-template> | ||
</thy-header> | ||
<thy-layout> | ||
<router-outlet></router-outlet> | ||
</thy-layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Component, OnInit, HostBinding } from '@angular/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'app2-detail', | ||
selector: 'app2-project-detail', | ||
templateUrl: './detail.component.html' | ||
}) | ||
export class ProjectDetailComponent implements OnInit { | ||
constructor() {} | ||
@HostBinding('class') class = 'thy-layout'; | ||
|
||
projectId: string; | ||
|
||
constructor(private route: ActivatedRoute, router: Router) { | ||
this.route.paramMap.subscribe(params => { | ||
this.projectId = params.get('id'); | ||
router.navigateByUrl(`/app2/projects/${this.projectId}/tasks`); | ||
}); | ||
} | ||
|
||
ngOnInit() {} | ||
} |
26 changes: 14 additions & 12 deletions
26
examples/app2/src/app/projects/project-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,29 @@ | ||
<input | ||
<thy-content> | ||
<input | ||
thyInput | ||
class="mt-2 mb-2" | ||
[(ngModel)]="search" | ||
placeholder="搜索项目" | ||
[style.width.px]="300" | ||
(thyEnter)="getProjects()" | ||
/> | ||
<thy-grid | ||
/> | ||
<thy-grid | ||
thyClassName="table-hover" | ||
[thyModel]="projects" | ||
[thyLoadingDone]="loadingDone" | ||
(thyOnRowClick)="openDetail()" | ||
(thyOnRowClick)="openDetail($event)" | ||
thyTheme="bordered" | ||
thyRowKey="id" | ||
> | ||
> | ||
<thy-grid-column thyTitle="名称" thyModelKey="name"></thy-grid-column> | ||
<thy-grid-column thyTitle="描述" thyModelKey="desc"></thy-grid-column> | ||
<thy-grid-column thyTitle="操作" thyClassName="thy-operation-links text-center"> | ||
<ng-template #cell let-row> | ||
<a href="javascript:;">设置</a> | ||
<a class="link-secondary" href="javascript:;"> | ||
<i class="wtf wtf-trash-o"></i> | ||
</a> | ||
</ng-template> | ||
<ng-template #cell let-row> | ||
<a href="javascript:;">设置</a> | ||
<a class="link-secondary" href="javascript:;"> | ||
<i class="wtf wtf-trash-o"></i> | ||
</a> | ||
</ng-template> | ||
</thy-grid-column> | ||
</thy-grid> | ||
</thy-grid> | ||
</thy-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Resolve, Router, ActivatedRouteSnapshot } from '@angular/router'; | ||
import { ProjectService } from './projects.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ProjectResolver implements Resolve<any> { | ||
constructor(private projectService: ProjectService, private router: Router) {} | ||
|
||
resolve(route: ActivatedRouteSnapshot) { | ||
const projectId = route.params.id; | ||
return this.projectService.fetchProject(projectId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<thy-header thySize="sm"> | ||
<ng-template #headerContent> | ||
<thy-nav thyType="thirdly" thyHorizontal="left"> | ||
<a thyNavLink [routerLink]="['./view-1']" routerLinkActive="active">View1</a> | ||
<a thyNavLink [routerLink]="['./view-2']" routerLinkActive="active">View2</a> | ||
<a thyNavLink [routerLink]="['./view-3']" routerLinkActive="active">View3</a> | ||
</thy-nav> | ||
</ng-template> | ||
</thy-header> | ||
<router-outlet></router-outlet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, OnInit, HostBinding } from '@angular/core'; | ||
import { Router, ActivatedRoute } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'app2-tasks', | ||
templateUrl: './tasks.component.html' | ||
}) | ||
export class TasksComponent implements OnInit { | ||
@HostBinding('class') class = 'thy-layout'; | ||
|
||
constructor(router: Router, route: ActivatedRoute) { | ||
router.navigate(['./view-1'], { relativeTo: route }); | ||
} | ||
|
||
ngOnInit(): void {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
viewId: {{ viewId }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Component, OnInit, HostBinding } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'app2-view', | ||
templateUrl: './view.component.html' | ||
}) | ||
export class ViewComponent implements OnInit { | ||
@HostBinding('class') class = 'thy-layout-content'; | ||
|
||
viewId: string; | ||
|
||
constructor(private route: ActivatedRoute) { | ||
route.paramMap.subscribe(param => { | ||
this.viewId = param.get('viewId'); | ||
}); | ||
} | ||
|
||
ngOnInit(): void {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
{ | ||
"extends": "../../tslint.json", | ||
"rules": { | ||
"directive-selector": [ | ||
true, | ||
"attribute", | ||
"app", | ||
"camelCase" | ||
], | ||
"component-selector": [ | ||
true, | ||
"element", | ||
"app", | ||
"kebab-case" | ||
] | ||
} | ||
"extends": "../../tslint.json", | ||
"rules": { | ||
"directive-selector": [true, "attribute", "app", "camelCase"], | ||
"component-selector": [true, "element", "app2", "kebab-case"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.