one way data binding by default
See original GitHub issueUse one way data binding only and by default as angular 1.5 uses
angular doesn’t copies those parent values, so if we have object and modify a property it will be mutated on parent, which is not very convenient. We wanna push best practices and stay immutable, so we will copy @Input
props via angular.copy
.
Although we should keep fallback for people which really need 2 way binding:
// one way only
@Component({
selector: 'hero',
template:`hello`
})
class HeroComponent{
@Input() name: string;
@Input() skills: string[];
}
// two-way fallback via alias only
@Component({
selector: 'hero',
template:`hello`
})
class HeroComponent{
@Input('=') name: string;
@Input('=') skills: string[];
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:12 (12 by maintainers)
Top Results From Across the Web
One-way and Two-way Data Binding in Angular | Pluralsight
One -way and two-way data binding are two of the important ways by which we can exchange data from component to DOM and...
Read more >Difference between One-way Binding and Two-way Binding
In one-way binding, the data flow is one-directional. · This means that the flow of code is from typescript file to Html file....
Read more >BindingMode Enum (System.Windows.Data) - Microsoft Learn
A programmatic way to determine whether a dependency property binds one-way or two-way by default is to get the property metadata of the...
Read more >Step 5: One-Way Data Binding - Documentation - SAPUI5 SDK
Any other binding instances will continue to use the model's default binding mode. For more information, see API Reference: sap.ui.base.ManagedObject.
Read more >aurelia - One way binding mode, the other way around
bind - Uses the default binding. One-way binding for everything but form controls, which use two-way binding. .one-way - Flows data one direction: ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yeah you’re right, so in your particular scenario just don’t use OnPush and use ChangeDetectorRef.
I will explore possibilities if it’s possible to tweak it to be more aligned with Angular 2, but that’s not the primary focus right now ( after ngMetadata 2.0 will be released )
Anyway, thanks for brilliant brainstorming ! These kind of conversations are golden!
closed by https://github.com/ngParty/ng-metadata/commit/7aee890639fe8796f4377908b202a94a8a3a9bec