import {
bootstrapApplication
} from '@angular/platform-browser';
@Component({
selector: 'hello-world',
standalone: true,
template: `Hello {{ world }}`
})
export class HelloWorld {
world = "World";
}
bootstrapApplication(HelloWorld);
Reactive Extensions Library for JavaScript
import { Component, signal, computed, effect } from '@angular/core';
@Component({
selector: 'planilha',
template: `
<table>
<tr>
<th>First</th>
<th>Last</th>
<th>Full Name</th>
</tr>
<tr>
<td>{{ firstName() }}</td>
<td>{{ lastName() }}</td>
<td>{{ fullName() }}</td>
</tr>
</table>`
})
export class Planilha {
firstName = signal("William");
lastName = signal("Grasel");
fullName = computed(() =>
this.firstName() + " " + this.lastName()
);
lastNameChange = effect(() => console.log(
"Last name changed: " + this.lastName()
));
}
import { HttpClient } from '@angular/common/http';
import { Component, inject } from '@angular/core';
import { User } from './user.interface';
import { toSignal } from '@angular/core/rxjs-interop';
@Component({
selector: 'app-root',
template: `
@if( user(); as data ) {
<h1>{{ data.title }}</h1>
}
`,
})
export class App {
http = inject(HttpClient);
user$ = this.http.get<User>("/user");
user = toSignal(this.user$); // Signal<User | undefined>
}
import { Component, Signal, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { FilterService } from './filter.service';
import { toObservable } from '@angular/core/rxjs-interop';
@Component({
selector: 'app-root',
template: `{{ results$ | async }}`,
})
export class App {
http = inject(HttpClient);
query = inject(FilterService).query; // Signal<string>
query$ = toObservable(this.query);
results$ = this.query$.pipe(
switchMap(query => this.http.get('/search?q=' + query ))
);
}