Skip to content
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {Component} from '@angular/core';
<code>{{ location.normalize('foo/bar') }}</code>
<br />
`,
standalone: false,
})
export class HashLocationComponent {
location: Location;
Expand Down
1 change: 1 addition & 0 deletions adev/src/content/api-examples/common/location/ts/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {PathLocationComponent} from './path_location_component';
<hash-location></hash-location>
<path-location></path-location>
`,
standalone: false,
})
export class AppComponent {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {Component} from '@angular/core';
<code>{{ location.normalize('foo/bar') }}</code>
<br />
`,
standalone: false,
})
export class PathLocationComponent {
location: Location;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ import {
import {BrowserModule} from '@angular/platform-browser';

// #docregion SimpleExample
@Component({selector: 'hello-world', template: 'Hello World!'})
@Component({
selector: 'hello-world',
template: 'Hello World!',
standalone: false,
})
export class HelloWorld {}

@Component({
selector: 'ng-component-outlet-simple-example',
template: `
<ng-container *ngComponentOutlet="HelloWorld"></ng-container>
`,
standalone: false,
})
export class NgComponentOutletSimpleExample {
// This field is necessary to expose HelloWorld to the template.
Expand All @@ -49,6 +54,7 @@ export class Greeter {
<ng-content></ng-content>
{{ greeter.suffix }}
`,
standalone: false,
})
export class CompleteComponent {
@Input() label!: string;
Expand All @@ -70,6 +76,7 @@ export class CompleteComponent {
"
></ng-container>
`,
standalone: false,
})
export class NgComponentOutletCompleteExample implements OnInit {
// This field is necessary to expose CompleteComponent to the template.
Expand Down Expand Up @@ -109,6 +116,7 @@ export class NgComponentOutletCompleteExample implements OnInit {
<hr />
<ng-component-outlet-complete-example></ng-component-outlet-complete-example>
`,
standalone: false,
})
export class AppComponent {}

Expand Down
5 changes: 5 additions & 0 deletions adev/src/content/api-examples/common/ngIf/ts/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {Subject} from 'rxjs';
<br />
<div *ngIf="show">Text to show</div>
`,
standalone: false,
})
export class NgIfSimple {
show = true;
Expand All @@ -35,6 +36,7 @@ export class NgIfSimple {
<div *ngIf="show; else elseBlock">Text to show</div>
<ng-template #elseBlock>Alternate text while primary text is hidden</ng-template>
`,
standalone: false,
})
export class NgIfElse {
show = true;
Expand All @@ -54,6 +56,7 @@ export class NgIfElse {
<ng-template #secondaryBlock>Secondary text to show</ng-template>
<ng-template #elseBlock>Alternate text while primary text is hidden</ng-template>
`,
standalone: false,
})
export class NgIfThenElse implements OnInit {
thenBlock: TemplateRef<any> | null = null;
Expand Down Expand Up @@ -83,6 +86,7 @@ export class NgIfThenElse implements OnInit {
</div>
<ng-template #loading let-user>Waiting... (user is {{ user | json }})</ng-template>
`,
standalone: false,
})
export class NgIfAs {
userObservable = new Subject<{first: string; last: string}>();
Expand Down Expand Up @@ -113,6 +117,7 @@ export class NgIfAs {
<ng-if-as></ng-if-as>
<hr />
`,
standalone: false,
})
export class AppComponent {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {BrowserModule} from '@angular/platform-browser';
<span>Ahoj {{ person }}!</span>
</ng-template>
`,
standalone: false,
})
export class NgTemplateOutletExample {
myContext = {$implicit: 'World', localSk: 'Svet'};
Expand All @@ -39,6 +40,7 @@ export class NgTemplateOutletExample {
template: `
<ng-template-outlet-example></ng-template-outlet-example>
`,
standalone: false,
})
export class AppComponent {}

Expand Down
2 changes: 2 additions & 0 deletions adev/src/content/api-examples/common/pipes/ts/async_pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {Observable, Observer} from 'rxjs';
<span>Wait for it... {{ greeting | async }}</span>
</div>
`,
standalone: false,
})
export class AsyncPromisePipeComponent {
greeting: Promise<string> | null = null;
Expand Down Expand Up @@ -53,6 +54,7 @@ export class AsyncPromisePipeComponent {
@Component({
selector: 'async-observable-pipe',
template: '<div><code>observable|async</code>: Time: {{ time | async }}</div>',
standalone: false,
})
export class AsyncObservablePipeComponent {
time = new Observable<string>((observer: Observer<string>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ registerLocaleData(localeFr);
<p>B: {{ b | currency : 'CLP' }}</p>
</div>
`,
standalone: false,
})
export class CurrencyPipeComponent {
a: number = 0.259;
Expand Down
2 changes: 2 additions & 0 deletions adev/src/content/api-examples/common/pipes/ts/date_pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ registerLocaleData(localeFr);
</p>
</div>
`,
standalone: false,
})
export class DatePipeComponent {
today = Date.now();
Expand All @@ -65,6 +66,7 @@ export class DatePipeComponent {
<p>The custom date is {{ today | date : 'yyyy-MM-dd HH:mm a' }}</p>
</div>
`,
standalone: false,
})
export class DeprecatedDatePipeComponent {
today = Date.now();
Expand Down
2 changes: 2 additions & 0 deletions adev/src/content/api-examples/common/pipes/ts/i18n_pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {Component} from '@angular/core';
template: `
<div>{{ messages.length | i18nPlural : messageMapping }}</div>
`,
standalone: false,
})
export class I18nPluralPipeComponent {
messages: any[] = ['Message 1'];
Expand All @@ -31,6 +32,7 @@ export class I18nPluralPipeComponent {
template: `
<div>{{ gender | i18nSelect : inviteMap }}</div>
`,
standalone: false,
})
export class I18nSelectPipeComponent {
gender: string = 'male';
Expand Down
1 change: 1 addition & 0 deletions adev/src/content/api-examples/common/pipes/ts/json_pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {Component} from '@angular/core';
<pre>{{ object | json }}</pre>
</div>
`,
standalone: false,
})
export class JsonPipeComponent {
object: Object = {foo: 'bar', baz: 'qux', nested: {xyz: 3, numbers: [1, 2, 3, 4, 5]}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {Component} from '@angular/core';
<div *ngFor="let item of map | keyvalue">{{ item.key }}:{{ item.value }}</div>
</span>
`,
standalone: false,
})
export class KeyValuePipeComponent {
object: {[key: number]: string} = {2: 'foo', 1: 'bar'};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {Component} from '@angular/core';
<pre>'{{ value | uppercase }}'</pre>
</div>
`,
standalone: false,
})
export class LowerUpperPipeComponent {
value: string = '';
Expand Down
1 change: 1 addition & 0 deletions adev/src/content/api-examples/common/pipes/ts/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {TitleCasePipeComponent} from './titlecase_pipe';
<h2><code>keyvalue</code></h2>
<keyvalue-pipe></keyvalue-pipe>
`,
standalone: false,
})
export class AppComponent {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ registerLocaleData(localeFr, 'fr');
</p>
</div>
`,
standalone: false,
})
export class NumberPipeComponent {
pi: number = 3.14159265359;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ registerLocaleData(localeFr);
<p>B: {{ b | percent : '4.3-5' : 'fr' }}</p>
</div>
`,
standalone: false,
})
export class PercentPipeComponent {
a: number = 0.259;
Expand Down
2 changes: 2 additions & 0 deletions adev/src/content/api-examples/common/pipes/ts/slice_pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {Component} from '@angular/core';
<p>{{ str }}[100]: '{{ str | slice : 100 }}' - output is expected to be ''</p>
</div>
`,
standalone: false,
})
export class SlicePipeStringComponent {
str: string = 'abcdefghij';
Expand All @@ -35,6 +36,7 @@ export class SlicePipeStringComponent {
<li *ngFor="let i of collection | slice : 1 : 3">{{ i }}</li>
</ul>
`,
standalone: false,
})
export class SlicePipeListComponent {
collection: string[] = ['a', 'b', 'c', 'd'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {Component} from '@angular/core';
<!-- output is expected to be "Foo-vs-bar" -->
</div>
`,
standalone: false,
})
export class TitleCasePipeComponent {}
// #enddocregion
6 changes: 5 additions & 1 deletion adev/src/content/api-examples/common/test_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import * as ngIfExample from './ngIf/ts/module';
import * as ngTemplateOutletExample from './ngTemplateOutlet/ts/module';
import * as pipesExample from './pipes/ts/module';

@Component({selector: 'example-app:not(y)', template: '<router-outlet></router-outlet>'})
@Component({
selector: 'example-app:not(y)',
template: '<router-outlet></router-outlet>',
standalone: false,
})
export class TestsAppComponent {}

@NgModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
<hr />
<div class="toggle-container" [@openClose]="stateExpression">Look at this box</div>
`,
standalone: false,
})
export class MyExpandoCmp {
// TODO(issue/24571): remove '!'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
// #docregion Component
import {Component, ContentChild, Directive, Input} from '@angular/core';

@Directive({selector: 'pane'})
@Directive({
selector: 'pane',
standalone: false,
})
export class Pane {
@Input() id!: string;
}
Expand All @@ -19,6 +22,7 @@ export class Pane {
template: `
<div>pane: {{ pane?.id }}</div>
`,
standalone: false,
})
export class Tab {
@ContentChild(Pane) pane!: Pane;
Expand All @@ -34,6 +38,7 @@ export class Tab {

<button (click)="toggle()">Toggle</button>
`,
standalone: false,
})
export class ContentChildComp {
shouldShow = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
// #docregion HowTo
import {AfterContentInit, ContentChild, Directive} from '@angular/core';

@Directive({selector: 'child-directive'})
@Directive({
selector: 'child-directive',
standalone: false,
})
class ChildDirective {}

@Directive({selector: 'someDir'})
@Directive({
selector: 'someDir',
standalone: false,
})
class SomeDir implements AfterContentInit {
@ContentChild(ChildDirective) contentChild!: ChildDirective;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
// #docregion Component
import {Component, ContentChildren, Directive, Input, QueryList} from '@angular/core';

@Directive({selector: 'pane'})
@Directive({
selector: 'pane',
standalone: false,
})
export class Pane {
@Input() id!: string;
}
Expand All @@ -20,6 +23,7 @@ export class Pane {
<div class="top-level">Top level panes: {{ serializedPanes }}</div>
<div class="nested">Arbitrary nested panes: {{ serializedNestedPanes }}</div>
`,
standalone: false,
})
export class Tab {
@ContentChildren(Pane) topLevelPanes!: QueryList<Pane>;
Expand Down Expand Up @@ -49,6 +53,7 @@ export class Tab {

<button (click)="show()">Show 3</button>
`,
standalone: false,
})
export class ContentChildrenComp {
shouldShow = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
// #docregion HowTo
import {AfterContentInit, ContentChildren, Directive, QueryList} from '@angular/core';

@Directive({selector: 'child-directive'})
@Directive({
selector: 'child-directive',
standalone: false,
})
class ChildDirective {}

@Directive({selector: 'someDir'})
@Directive({
selector: 'someDir',
standalone: false,
})
class SomeDir implements AfterContentInit {
@ContentChildren(ChildDirective) contentChildren!: QueryList<ChildDirective>;

Expand Down
7 changes: 6 additions & 1 deletion adev/src/content/api-examples/core/di/ts/metadata_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';
class OtherService {}
class HostService {}

@Directive({selector: 'child-directive'})
@Directive({
selector: 'child-directive',
standalone: false,
})
class ChildDirective {
logs: string[] = [];

Expand All @@ -157,13 +160,15 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';
selector: 'parent-cmp',
viewProviders: [HostService],
template: '<child-directive></child-directive>',
standalone: false,
})
class ParentCmp {}

@Component({
selector: 'app',
viewProviders: [OtherService],
template: '<parent-cmp></parent-cmp>',
standalone: false,
})
class App {}
// #enddocregion
Expand Down
Loading