+
Optimized for Angular
Get started
-
+
diff --git a/src/app/shared/doc-viewer/doc-viewer.spec.ts b/src/app/shared/doc-viewer/doc-viewer.spec.ts
index ca491a78b..693051def 100644
--- a/src/app/shared/doc-viewer/doc-viewer.spec.ts
+++ b/src/app/shared/doc-viewer/doc-viewer.spec.ts
@@ -22,38 +22,37 @@ describe('DocViewer', () => {
}));
it('should load doc into innerHTML', () => {
- let fixture = TestBed.createComponent(DocViewerTestComponent);
+ const fixture = TestBed.createComponent(DocViewerTestComponent);
fixture.detectChanges();
const url = fixture.componentInstance.documentUrl;
http.expectOne(url).flush(FAKE_DOCS[url]);
- let docViewer = fixture.debugElement.query(By.directive(DocViewer));
+ const docViewer = fixture.debugElement.query(By.directive(DocViewer));
expect(docViewer).not.toBeNull();
expect(docViewer.nativeElement.innerHTML).toBe('
my docs page
');
});
it('should save textContent of the doc', () => {
- let fixture = TestBed.createComponent(DocViewerTestComponent);
+ const fixture = TestBed.createComponent(DocViewerTestComponent);
fixture.detectChanges();
const url = fixture.componentInstance.documentUrl;
http.expectOne(url).flush(FAKE_DOCS[url]);
- let docViewer = fixture.debugElement.query(By.directive(DocViewer));
+ const docViewer = fixture.debugElement.query(By.directive(DocViewer));
expect(docViewer.componentInstance.textContent).toBe('my docs page');
});
-
it('should correct hash based links', () => {
- let fixture = TestBed.createComponent(DocViewerTestComponent);
+ const fixture = TestBed.createComponent(DocViewerTestComponent);
fixture.componentInstance.documentUrl = `http://material.angular.io/doc-with-links.html`;
fixture.detectChanges();
const url = fixture.componentInstance.documentUrl;
http.expectOne(url).flush(FAKE_DOCS[url]);
- let docViewer = fixture.debugElement.query(By.directive(DocViewer));
+ const docViewer = fixture.debugElement.query(By.directive(DocViewer));
// Our test runner runs at the page /context.html, so it will be the prepended value.
expect(docViewer.nativeElement.innerHTML).toContain(`/context.html#test"`);
});
diff --git a/src/app/shared/doc-viewer/doc-viewer.ts b/src/app/shared/doc-viewer/doc-viewer.ts
index 4163a0f0d..ed159cdab 100644
--- a/src/app/shared/doc-viewer/doc-viewer.ts
+++ b/src/app/shared/doc-viewer/doc-viewer.ts
@@ -1,4 +1,4 @@
-import {ComponentPortal, DomPortalHost} from '@angular/cdk/portal';
+import {ComponentPortal, DomPortalOutlet} from '@angular/cdk/portal';
import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import {DomSanitizer} from '@angular/platform-browser';
import {
@@ -25,7 +25,7 @@ import {HeaderLink} from './header-link';
template: 'Loading document...',
})
export class DocViewer implements OnDestroy {
- private _portalHosts: DomPortalHost[] = [];
+ private _portalHosts: DomPortalOutlet[] = [];
private _documentFetchSubscription: Subscription;
@Input() name: string;
@@ -102,15 +102,15 @@ export class DocViewer implements OnDestroy {
/** Instantiate a ExampleViewer for each example. */
private _loadComponents(componentName: string, componentClass: any) {
- let exampleElements =
+ const exampleElements =
this._elementRef.nativeElement.querySelectorAll(`[${componentName}]`);
Array.prototype.slice.call(exampleElements).forEach((element: Element) => {
- let example = element.getAttribute(componentName);
- let portalHost = new DomPortalHost(
+ const example = element.getAttribute(componentName);
+ const portalHost = new DomPortalOutlet(
element, this._componentFactoryResolver, this._appRef, this._injector);
- let examplePortal = new ComponentPortal(componentClass, this._viewContainerRef);
- let exampleViewer = portalHost.attach(examplePortal);
+ const examplePortal = new ComponentPortal(componentClass, this._viewContainerRef);
+ const exampleViewer = portalHost.attach(examplePortal);
if (example !== null) {
(exampleViewer.instance as ExampleViewer).example = example;
}
diff --git a/src/app/shared/doc-viewer/header-link.ts b/src/app/shared/doc-viewer/header-link.ts
index 1f40f4aab..ed1721fb0 100644
--- a/src/app/shared/doc-viewer/header-link.ts
+++ b/src/app/shared/doc-viewer/header-link.ts
@@ -17,12 +17,8 @@ import {Router} from '@angular/router';
@Component({
selector: 'header-link',
template: `
-
+
link
`
diff --git a/src/app/shared/documentation-items/documentation-items.ts b/src/app/shared/documentation-items/documentation-items.ts
index c9322f95b..c5b7d5ac9 100644
--- a/src/app/shared/documentation-items/documentation-items.ts
+++ b/src/app/shared/documentation-items/documentation-items.ts
@@ -583,14 +583,14 @@ const DOCS: {[key: string]: DocCategory[]} = {
]
};
-for (let category of DOCS[COMPONENTS]) {
- for (let doc of category.items) {
+for (const category of DOCS[COMPONENTS]) {
+ for (const doc of category.items) {
doc.packageName = 'material';
}
}
-for (let category of DOCS[CDK]) {
- for (let doc of category.items) {
+for (const category of DOCS[CDK]) {
+ for (const doc of category.items) {
doc.packageName = 'cdk';
}
}
@@ -619,11 +619,11 @@ export class DocumentationItems {
}
getItemById(id: string, section: string): DocItem | undefined {
- const sectionLookup = section == 'cdk' ? 'cdk' : 'material';
- return ALL_DOCS.find(doc => doc.id === id && doc.packageName == sectionLookup);
+ const sectionLookup = section === 'cdk' ? 'cdk' : 'material';
+ return ALL_DOCS.find(doc => doc.id === id && doc.packageName === sectionLookup);
}
getCategoryById(id: string): DocCategory | undefined {
- return ALL_CATEGORIES.find(c => c.id == id);
+ return ALL_CATEGORIES.find(c => c.id === id);
}
}
diff --git a/src/app/shared/example-viewer/example-viewer.html b/src/app/shared/example-viewer/example-viewer.html
index 65b052021..be0472f68 100644
--- a/src/app/shared/example-viewer/example-viewer.html
+++ b/src/app/shared/example-viewer/example-viewer.html
@@ -3,7 +3,7 @@
{{exampleData?.title}}