mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
docs: remove Component and Directives (#45828)
Move all content to example-zippy.component.ts PR Close #45828
This commit is contained in:
parent
008111d2c2
commit
57fa804bb2
1 changed files with 1 additions and 36 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue