Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: remove Component and Directives (#45828)
Move all content to example-zippy.component.ts PR Close #45828
- Loading branch information
1 parent
008111d
commit 57fa804
Showing
1 changed file
with
1 addition
and
36 deletions.
There are no files selected for viewing
37 changes: 1 addition & 36 deletions
37
aio/content/examples/content-projection/src/app/app.component.ts
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,42 +1,7 @@ | ||
import { Component, Directive, Input, TemplateRef, ContentChild, HostBinding, HostListener } from '@angular/core'; | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html' | ||
}) | ||
export class AppComponent {} | ||
|
||
@Directive({ | ||
selector: 'button[appExampleZippyToggle]', | ||
}) | ||
export class ZippyToggleDirective { | ||
@HostBinding('attr.aria-expanded') ariaExpanded = this.zippy.expanded; | ||
@HostBinding('attr.aria-controls') ariaControls = this.zippy.contentId; | ||
@HostListener('click') toggleZippy() { | ||
this.zippy.expanded = !this.zippy.expanded; | ||
} | ||
constructor(public zippy: ZippyComponent) {} | ||
} | ||
|
||
// #docregion zippycontentdirective | ||
@Directive({ | ||
selector: '[appExampleZippyContent]' | ||
}) | ||
export class ZippyContentDirective { | ||
constructor(public templateRef: TemplateRef<unknown>) {} | ||
} | ||
// #enddocregion zippycontentdirective | ||
|
||
let nextId = 0; | ||
|
||
@Component({ | ||
selector: 'app-example-zippy', | ||
templateUrl: 'example-zippy.template.html', | ||
}) | ||
export class ZippyComponent { | ||
contentId = `zippy-${nextId++}`; | ||
@Input() expanded = false; | ||
// #docregion contentchild | ||
@ContentChild(ZippyContentDirective) content!: ZippyContentDirective; | ||
// #enddocregion contentchild | ||
} |