angular/packages/core
Kristiyan Kostadinov 331b16efd2 feat(core): add API to inject attributes on the host node (#54604)
Angular has the `@Attribute` decorator that allows for attributes to be injected from the host node, but we don't have an equivalent for the `inject` function. These changes introduce the new `HostAttributeToken` class that can be used to inject attributes similarly to `@Attribute`. It can be used as follows:

```typescript
import {HostAttributeToken, inject} from '@angular/core';

class MyDir {
  someAttr = inject(new HostAttributeToken('some-attr'));
}
```

The new API works similarly to `@Attribute` with one key exception: it will throw a DI error when the attribute doesn't exist, instead of returning `null` like `@Attribute`. We made this change to align its behavior closer to other injection tokens.

PR Close #54604
2024-02-27 15:18:41 -08:00
..
global docs(docs-infra): Add missing API entries to ADEV (#54530) 2024-02-21 16:41:33 +00:00
primitives/signals refactor(core): rework runtime implementation to simplify and fix issues (#54103) 2024-02-06 15:04:36 +00:00
reference-manifests build: add target to generate api manifest (#52472) 2023-11-02 11:00:59 -07:00
rxjs-interop build: configure cross-pkg resolution for api extraction (#52499) 2024-01-05 11:27:34 -08:00
schematics fix(migrations): resolve infinite loop for a single line element with a long tag name and angle bracket on a new line (#54588) 2024-02-23 11:40:27 -08:00
src feat(core): add API to inject attributes on the host node (#54604) 2024-02-27 15:18:41 -08:00
test feat(core): add API to inject attributes on the host node (#54604) 2024-02-27 15:18:41 -08:00
testing fix(core): update imports to be compatible with rxjs 6 (#54193) 2024-02-01 20:48:19 +00:00
BUILD.bazel docs(docs-infra): Add missing API entries to ADEV (#54530) 2024-02-21 16:41:33 +00:00
index.ts refactor(core): made comment structure consistent in index.ts (#43684) 2021-10-21 18:39:58 +00:00
package.json build: update node.js engines version to be more explicate about v20 support (#52448) 2023-10-31 14:18:36 -07:00
PACKAGE.md docs: add package doc files (#26047) 2018-10-05 15:42:14 -07:00
public_api.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00