https://github.com/angular/angular
Revision 702ab28b4c07a903c403a20af2ca287348b6afd0 authored by Kristiyan Kostadinov on 05 February 2024, 18:18:10 UTC, committed by Jessica Janiuk on 07 February 2024, 16:36:09 UTC
Adds support for model inputs in the framework. `model()` returns a writable signal that implicitly defines a input/output pair that can be used either in two-way bindings to keep two values in sync or by binding individually to the input and output. When the value of the `model` changes, it will emit an event with the current value.

Furthermore, these changes expand two-way bindings to accept `WritableSignal`. This will make it easier to transition existing code to signals in a backwards-compatible way.

Example:

```ts
@Directive({
  selector: 'counter',
  standalone: true,
  host: {
    '(click)': 'increment()',
  }
})
export class Counter {
  value = model(0);

  increment(): void {
    this.value.update(current => current + 1);
  }
}

@Component({
  template: `<counter [(value)]="count"/> The current count is: {{count()}}`,
})
class App {
  count = signal(0);
}
```

PR Close #54252
1 parent d006aa3
History
Tip revision: 702ab28b4c07a903c403a20af2ca287348b6afd0 authored by Kristiyan Kostadinov on 05 February 2024, 18:18:10 UTC
feat(core): add support for model inputs (#54252)
Tip revision: 702ab28
File Mode Size
.circleci
.devcontainer
.github
.husky
.ng-dev
.vscode
.yarn
adev
aio
devtools
docs
goldens
integration
modules
packages
scripts
third_party
tools
.bazelignore -rw-r--r-- 1.6 KB
.bazelrc -rw-r--r-- 7.7 KB
.bazelversion -rw-r--r-- 6 bytes
.clang-format -rw-r--r-- 73 bytes
.editorconfig -rw-r--r-- 245 bytes
.gitattributes -rw-r--r-- 146 bytes
.gitignore -rw-r--r-- 1004 bytes
.gitmessage -rw-r--r-- 7.2 KB
.mailmap -rw-r--r-- 51 bytes
.npmrc -rw-r--r-- 21 bytes
.nvmrc -rw-r--r-- 8 bytes
.prettierrc -rw-r--r-- 157 bytes
.pullapprove.yml -rw-r--r-- 52.3 KB
.yarnrc -rw-r--r-- 130 bytes
BUILD.bazel -rw-r--r-- 2.5 KB
CHANGELOG.md -rw-r--r-- 266.9 KB
CHANGELOG_ARCHIVE.md -rw-r--r-- 997.0 KB
CODE_OF_CONDUCT.md -rw-r--r-- 3.6 KB
CONTRIBUTING.md -rw-r--r-- 15.7 KB
LICENSE -rw-r--r-- 1.1 KB
README.md -rw-r--r-- 5.5 KB
SECURITY.md -rw-r--r-- 403 bytes
WORKSPACE -rw-r--r-- 8.9 KB
browser-providers.conf.d.ts -rw-r--r-- 387 bytes
browser-providers.conf.js -rw-r--r-- 1.9 KB
gulpfile.js -rw-r--r-- 572 bytes
karma-js.conf.js -rw-r--r-- 6.0 KB
package.json -rw-r--r-- 9.9 KB
packages.bzl -rw-r--r-- 3.8 KB
renovate.json -rw-r--r-- 3.0 KB
tsconfig-tslint.json -rw-r--r-- 171 bytes
tslint.json -rw-r--r-- 5.3 KB
yarn.bzl -rw-r--r-- 77 bytes
yarn.lock -rw-r--r-- 779.8 KB
yarn.lock.readme.md -rw-r--r-- 1.3 KB

README.md

back to top