Thanks to visit codestin.com
Credit goes to github.com

Skip to content

docs(template): add setup example with standalone cmp and fix typos #1558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ class Component {
### Template

```ts
import { LetModule } from '@rx-angular/template/let';
import { ForModule } from '@rx-angular/template/for';
import { PushModule } from '@rx-angular/template/push';
import { LetDirective } from '@rx-angular/template/let';
import { PushPipe } from '@rx-angular/template/push';
import { RxFor } from '@rx-angular/template/for';

@Module({
imports: [LetModule, ForModule, PushModule],
imports: [LetDirective, PushPipe, RxFor],
})
class Module {}
```
Expand Down
42 changes: 15 additions & 27 deletions apps/docs/docs/template/api/let-directive.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,14 @@ n/a

## Setup

The `LetModule` can be imported as following:

Module based setup:

```ts
import { LetModule } from '@rx-angular/template/let';

@NgModule({
imports: [LetModule],
// ...
})
export class AnyModule {}
```

Standalone component setup:
The `LetDirective` can be imported as following:

```ts
import { LetModule } from '@rx-angular/template/let';
import { LetDirective } from '@rx-angular/template/let';

@Component({
standalone: true,
imports: [LetModule],
imports: [LetDirective],
template: `...`,
})
export class AnyComponent {}
Expand Down Expand Up @@ -237,7 +223,7 @@ e.g. from the complete template back to the value display

```typescript
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<button (click)="nextTrigger$.next()">show value</button>
<ng-container
Expand All @@ -263,7 +249,7 @@ e.g. from the complete template back to the value display

```typescript
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<ng-container *rxLet="num$; let n; error: error; errorTrg: errorTrigger$">
{{ n }}
Expand All @@ -286,7 +272,7 @@ e.g. from the complete template back to the value display

```typescript
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<ng-container
*rxLet="num$; let n; complete: complete; completeTrg: completeTrigger$"
Expand All @@ -311,7 +297,7 @@ e.g. from the complete template back to the value display

```typescript
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<input (input)="search($event.target.value)" />
<ng-container
Expand Down Expand Up @@ -348,7 +334,7 @@ in a convenient way.

```typescript
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<input (input)="search($event.target.value)" />
<ng-container
Expand Down Expand Up @@ -392,7 +378,9 @@ The default value for strategy is [`normal`](../../cdk/render-strategies/strateg
```

```ts
@Component()
@Component({
/**/
})
export class AppComponent {
strategy = 'low';
strategy$ = of('immediate');
Expand Down Expand Up @@ -447,9 +435,9 @@ The result of the `renderCallback` will contain the currently rendered value of
@Component({
selector: 'app-root',
template: `
<ng-container *rxLet="num$; let n; renderCallback: valueRendered;">
{{ n }}
</ng-container>
<ng-container *rxLet="num$; let n; renderCallback: valueRendered;">
{{ n }}
</ng-container>
`
})
export class AppComponent {
Expand Down Expand Up @@ -477,7 +465,7 @@ For more details read about [NgZone optimizations](../performance-issues/ngzone-

```ts
@Component({
selector: 'any-component>',
selector: 'app-root',
template: `
<div
*rxLet="bgColor$; let bgColor; patchZone: false"
Expand Down
50 changes: 19 additions & 31 deletions apps/docs/docs/template/api/rx-for-directive.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,14 @@ The following context variables are available for each template:

## Setup

The `ForModule` can be imported as following:

Module based setup:

```
import { ForModule } from "@rx-angular/template/for";

@NgModule({
imports: [ ForModule ],
// ...
})
export class AnyModule {}
```

Standalone component setup:
The `RxFor` can be imported as following:

```
import { ForModule } from "@rx-angular/template/for";
import { RxFor } from "@rx-angular/template/for";

@NgComponent({
@Component({
standalone: true,
imports: [ ForModule ],
imports: [RxFor],
template: `...`
})
export class AnyComponent {}
Expand All @@ -151,11 +137,11 @@ export class AnyComponent {}
### Simple example using `*rxFor` with `Observable` values

```ts
@NgComponent({
@Component({
template: `
<ul>
<li *rxFor="let item of items$; trackBy: trackItem">{{ item }}</li>
</ul>
<ul>
<li *rxFor="let item of items$; trackBy: trackItem">{{ item }}</li>
</ul>
`
})
export class AnyComponent {
Expand All @@ -173,11 +159,11 @@ export class AnyComponent {
> As `rxFor` accepts also static values it can serve as a drop in replacement with an easy find and replace refactoring.

```typescript
@NgComponent({
@Component({
template: `
<ul>
<li *rxFor="let item of items; trackBy: trackItem">{{ item }}</li>
</ul>
<ul>
<li *rxFor="let item of items; trackBy: trackItem">{{ item }}</li>
</ul>
`
})
export class AnyComponent {
Expand All @@ -195,12 +181,12 @@ export class AnyComponent {
> As `rxFor` accepts also static values it can serve as a drop in replacement with an easy find and replace refacturing.

```typescript
@NgComponent({
@Component({
template: `
<ul>
<li *rxFor="let item of items; trackBy: 'id'">{{ item }}</li>
</ul>
`,
`,
})
export class AnyComponent {}
```
Expand Down Expand Up @@ -272,7 +258,9 @@ The default value for strategy is [`normal`](../../cdk/render-strategies/strateg
```

```ts
@Component()
@Component({
/**/
})
export class AppComponent {
strategy = 'low';
strategy$ = of('immediate');
Expand Down Expand Up @@ -303,7 +291,7 @@ Imagine the following situation:
template: ` <ng-content select="app-list-item"></ng-content>`,
})
export class AppListComponent {
@ContentChildren(AppListItemComponent)
@ContentChildren(AppListItemComponent);
appListItems: QueryList<AppListItemComponent>;
}
```
Expand Down Expand Up @@ -436,7 +424,7 @@ For more details read about [NgZone optimizations](../performance-issues/ngzone-

```ts
@Component({
selector: 'any-component>',
selector: 'app-root',
template: `
<div
*rxFor="let bgColor; in: bgColor$; patchZone: false"
Expand Down
32 changes: 9 additions & 23 deletions apps/docs/docs/template/api/rx-if-directive.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,14 @@ n/a

## Setup

The `IfModule` can be imported as following:

Module based setup:

```ts
import { IfModule } from '@rx-angular/template/if';

@NgModule({
imports: [IfModule],
// ...
})
export class AnyModule {}
```

Standalone component setup:
The `RxIf` can be imported as following:

```ts
import { IfModule } from '@rx-angular/template/if';
import { RxIf } from '@rx-angular/template/if';

@Component({
standalone: true,
imports: [IfModule],
imports: [RxIf],
template: `...`,
})
export class AnyComponent {}
Expand Down Expand Up @@ -287,7 +273,7 @@ e.g. from the complete template back to the value display

```typescript
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<button (click)="nextTrigger$.next()">show value</button>
<ng-container *rxIf="show; complete: complete; nextTrg: nextTrigger$">
Expand All @@ -309,7 +295,7 @@ e.g. from the complete template back to the value display

```typescript
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<ng-container *rxIf="show$; let n; error: error; errorTrg: errorTrigger$">
<item></item>
Expand All @@ -330,7 +316,7 @@ e.g. from the complete template back to the value display

```typescript
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<ng-container
*rxIf="show$; complete: complete; completeTrg: completeTrigger$"
Expand All @@ -353,7 +339,7 @@ e.g. from the complete template back to the value display

```typescript
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<input (input)="search($event.target.value)" />
<ng-container
Expand Down Expand Up @@ -384,7 +370,7 @@ in a convenient way.

```typescript
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<input (input)="search($event.target.value)" />
<ng-container *rxIf="show$; suspense: suspense; contextTrg: contextTrg$">
Expand Down Expand Up @@ -504,7 +490,7 @@ For more details read about [NgZone optimizations](../performance-issues/ngzone-

```ts
@Component({
selector: 'any-component',
selector: 'app-root',
template: `
<div *rxIf="enabled$; patchZone: false" (drag)="itemDrag($event)"></div>
`,
Expand Down
22 changes: 12 additions & 10 deletions libs/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,21 @@ nx migrate @rx-angular/template

## Basic setup

You can import each feature module individually.
You can import each feature individually.

```typescript
import { LetModule } from '@rx-angular/template/let';
import { ForModule } from '@rx-angular/template/for';
import { PushModule } from '@rx-angular/template/push';
import { UnpatchModule } from '@rx-angular/template/unpatch';

@NgModule({
declarations: [...],
imports: [ForModule, LetModule, PushModule, UnpatchModule],
import { LetDirective } from '@rx-angular/template/let';
import { RxFor } from '@rx-angular/template/for';
import { RxIf } from '@rx-angular/template/if';
import { PushPipe } from '@rx-angular/template/push';
import { UnpatchDirective } from '@rx-angular/template/unpatch';

@Component({
standalone: true,
imports: [LetDirective, RxFor, RxIf, PushPipe, UnpatchDirective],
template: `...`,
})
export class MyModule {}
export class AnyComponent {}
```

## Version Compatibility
Expand Down