Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Proposal for one-way binding option #13900

Closed
robstove opened this issue Jan 30, 2016 · 2 comments
Closed

Proposal for one-way binding option #13900

robstove opened this issue Jan 30, 2016 · 2 comments

Comments

@robstove
Copy link

I'd like to propose a way to allow directives to support one-way binding. Currently this is not an option and the only way to capture data from parent scope is by using two-way '=' binding or '&' binding. '&' binding would work but creates a semantic issue because it is expression based. To solve this a new binding option needs to be added so that we can do something like this:

scope: {
    myOneWayProperty: '-'
}

When the one-way binding option is specified this indicates that the scope property should be replaced with the evaluated value from $parent scope.

scope.myOneWayProperty = $parse(scope.myOneWayProperty)(scope.$parent);

With this option we can now pass objects to a directive without the need for two watches and without having function callback semantic

@Narretz
Copy link
Contributor

Narretz commented Jan 30, 2016

Let's discuss this centralized here: #13854

@Narretz Narretz closed this as completed Jan 30, 2016
@robstove
Copy link
Author

Perfect thanks Martin!

petebacondarwin pushed a commit that referenced this issue Feb 3, 2016
This change allows the developer to bind an isolate scope / controller property
to an expression, using a `<` binding, in such a way that if the value of the
expression changes, the scope/controller property is updated but not the
converse.

This makes it easier to build AngularJS applications that have unidirectional
data flow.

The binding is implemented simply as a single watch, which can also provide
performance benefits over two way bindings.

Closes #13928
Closes #13854
Closes #12835
Closes #13900
petebacondarwin pushed a commit that referenced this issue Feb 3, 2016
This change allows the developer to bind an isolate scope / controller property
to an expression, using a `<` binding, in such a way that if the value of the
expression changes, the scope/controller property is updated but not the
converse.

The binding is implemented as a single simple watch, which can also provide
performance benefits over two way bindings.

Closes #13928
Closes #13854
Closes #12835
Closes #13900
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants