angular/packages/core
Kristiyan Kostadinov 8f3d0b9d97 feat(core): introduce @Service decorator
These changes introduce the new `@Service` decorator which is a more ergonomic alternative to `@Injectable`. The reason we're adding a new decorator is that `@Injectable` has been around since the beginning of Angular and it has a lot of baggage that adds unnecessary overhead for users that generally want to define a singleton service, available in their entire app. The key differences between `@Service` and `@Injectable` are:
1. `@Service` is `providedIn: 'root'` by default. You can opt into providing the service yourself by setting `autoProvided: false` on it.
2. `@Service` doesn't allow constructor-based injection, only the `inject` function.
3. `@Service` doesn't support the complex type signature of `@Injectable` (`useClass`, `useValue` etc.). Instead it supports a single `factory` function.

Example:

```ts
import {Service} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {AuthService} from './auth';

@Service()
export class PostService {
  private readonly httpClient = inject(HttpClient);
  private readonly authService = inject(AuthService);

  getUserPosts() {
    return this.httpClient.get('/api/posts/' + this.authService.userId);
  }
}
```
2026-04-22 11:01:01 -07:00
..
global build: rename defaults2.bzl to defaults.bzl (#63383) 2025-08-25 15:45:01 -07:00
primitives fix(core): remove obsolete iOS cursor pointer hack in event delegation 2026-04-08 11:31:30 -07:00
resources fix(core): Remove note to skip arrow functions in best practices 2026-01-20 10:42:42 -08:00
rxjs-interop feat(core): allow synchronous values for stream Resources 2026-04-16 00:13:04 +03:00
schematics fix(migrations): fix NgClass leaving trailing comma after removal 2026-04-22 09:59:49 -07:00
src feat(core): introduce @Service decorator 2026-04-22 11:01:01 -07:00
test feat(core): introduce @Service decorator 2026-04-22 11:01:01 -07:00
testing refactor(core): simplifying the ComponentFactory usage 2026-04-13 22:24:18 +03:00
BUILD.bazel refactor(core): export profile event as enum and move profile_types.ts and framework to shared devtools folder 2025-11-19 15:22:49 -08:00
index.ts
package.json build: update minimum supported Node.js versions 2026-02-25 07:57:18 -08:00
PACKAGE.md build: format md files 2025-11-06 10:03:05 -08:00
public_api.ts
tsconfig-build.json
tsconfig-test.json