docs: convert the last my-app components to app-root (#42256)

Most of these were fixed in other PRs but there were are couple of stragglers.
Note that `my-app` components in non-documentation facing code, such as
compliance tests have not been changed.

Fixes #20235

PR Close #42256
This commit is contained in:
Pete Bacon Darwin 2021-05-23 20:40:01 +01:00 committed by Zach Arend
parent 6da0c97423
commit c2ed612da3
12 changed files with 29 additions and 23 deletions

View File

@ -1,7 +1,7 @@
import { Component, VERSION } from '@angular/core'; import { Component, VERSION } from '@angular/core';
@Component({ @Component({
selector: 'my-app', selector: 'app-root',
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ] styleUrls: [ './app.component.css' ]
}) })

View File

@ -4,6 +4,6 @@
<title>Angular App</title> <title>Angular App</title>
</head> </head>
<body> <body>
<my-app>loading</my-app> <app-root>loading</app-root>
</body> </body>
</html> </html>

View File

@ -156,7 +156,7 @@ The `AppComponent` template uses this component as follows:
```ts ```ts
@Component({ @Component({
selector: 'my-app', selector: 'app-root',
template: '<user-detail [user]="selectedUser" />', template: '<user-detail [user]="selectedUser" />',
}) })
export class AppComponent { export class AppComponent {

View File

@ -17,7 +17,7 @@ export class TooltipDirective {
} }
@Component({ @Component({
selector: 'my-app', selector: 'app-root',
template: 'Hello World!' template: 'Hello World!'
}) })
class MyAppComponent { class MyAppComponent {

View File

@ -31,17 +31,19 @@ import {getTNode, unwrapRNode} from './view_utils';
* *
* @usageNotes * @usageNotes
* Given the following DOM structure: * Given the following DOM structure:
*
* ```html * ```html
* <my-app> * <app-root>
* <div> * <div>
* <child-comp></child-comp> * <child-comp></child-comp>
* </div> * </div>
* </my-app> * </app-root>
* ``` * ```
*
* Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent` * Calling `getComponent` on `<child-comp>` will return the instance of `ChildComponent`
* associated with this DOM element. * associated with this DOM element.
* *
* Calling the function on `<my-app>` will return the `MyApp` instance. * Calling the function on `<app-root>` will return the `MyApp` instance.
* *
* *
* @param element DOM element from which the component should be retrieved. * @param element DOM element from which the component should be retrieved.
@ -177,12 +179,14 @@ export function getInjectionTokens(element: Element): any[] {
* *
* @usageNotes * @usageNotes
* Given the following DOM structure: * Given the following DOM structure:
* ``` *
* <my-app> * ```html
* <app-root>
* <button my-button></button> * <button my-button></button>
* <my-comp></my-comp> * <my-comp></my-comp>
* </my-app> * </app-root>
* ``` * ```
*
* Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton` * Calling `getDirectives` on `<button>` will return an array with an instance of the `MyButton`
* directive that is associated with the DOM node. * directive that is associated with the DOM node.
* *
@ -360,14 +364,16 @@ export interface Listener {
* *
* @usageNotes * @usageNotes
* Given the following DOM structure: * Given the following DOM structure:
* ```
* <my-app>
* <div (click)="doSomething()"></div>
* </my-app>
* *
* ```html
* <app-root>
* <div (click)="doSomething()"></div>
* </app-root>
* ``` * ```
*
* Calling `getListeners` on `<div>` will return an object that looks as follows: * Calling `getListeners` on `<div>` will return an object that looks as follows:
* ``` *
* ```ts
* { * {
* name: 'click', * name: 'click',
* element: <div>, * element: <div>,

View File

@ -109,7 +109,7 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
* *
* ```typescript * ```typescript
* @Component({ * @Component({
* selector: 'my-app', * selector: 'app-root',
* template: `Number of ticks: {{numberOfTicks}}` * template: `Number of ticks: {{numberOfTicks}}`
* changeDetection: ChangeDetectionStrategy.OnPush, * changeDetection: ChangeDetectionStrategy.OnPush,
* }) * })
@ -231,7 +231,7 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
* } * }
* *
* @Component({ * @Component({
* selector: 'my-app', * selector: 'app-root',
* providers: [DataProvider], * providers: [DataProvider],
* template: ` * template: `
* Live Update: <input type="checkbox" [(ngModel)]="live"> * Live Update: <input type="checkbox" [(ngModel)]="live">

View File

@ -11,7 +11,7 @@ import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
@Component({selector: 'my-app', template: 'empty'}) @Component({selector: 'app-root', template: 'empty'})
class MyApp { class MyApp {
} }

View File

@ -10,7 +10,7 @@ import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
@Component({selector: 'my-app', template: 'Hello {{ name }}!'}) @Component({selector: 'app-root', template: 'Hello {{ name }}!'})
class MyApp { class MyApp {
name: string = 'World'; name: string = 'World';
} }

View File

@ -12,7 +12,7 @@ import {FormsModule} from '@angular/forms';
// #docregion mark-for-check // #docregion mark-for-check
@Component({ @Component({
selector: 'my-app', selector: 'app-root',
template: `Number of ticks: {{numberOfTicks}}`, template: `Number of ticks: {{numberOfTicks}}`,
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })

View File

@ -10,7 +10,7 @@ import {Component, ViewEncapsulation} from '@angular/core';
// #docregion longform // #docregion longform
@Component({ @Component({
selector: 'my-app', selector: 'app-root',
template: ` template: `
<h1>Hello World!</h1> <h1>Hello World!</h1>
<span class="red">Shadow DOM Rocks!</span> <span class="red">Shadow DOM Rocks!</span>

View File

@ -10,7 +10,7 @@ import {Component, createPlatformFactory} from '@angular/core';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
// #docregion longform // #docregion longform
@Component({selector: 'my-app', template: 'Hello World'}) @Component({selector: 'app-root', template: 'Hello World'})
class MyApp { class MyApp {
} }

View File

@ -24,7 +24,7 @@ import {ɵresetJitOptions as resetJitOptions} from '@angular/core';
* *
* ``` * ```
* describe('something', () => { * describe('something', () => {
* it('should do something', withBody('<my-app></my-app>', async () => { * it('should do something', withBody('<app-root></app-root>', async () => {
* const myApp = renderComponent(MyApp); * const myApp = renderComponent(MyApp);
* await whenRendered(myApp); * await whenRendered(myApp);
* expect(getRenderedText(myApp)).toEqual('Hello World!'); * expect(getRenderedText(myApp)).toEqual('Hello World!');