feat($compile): add one-way binding to the isolate scope defintion#13928
feat($compile): add one-way binding to the isolate scope defintion#13928Narretz wants to merge 6 commits intoangular:masterfrom
Conversation
6987dd8 to
bd1f619
Compare
src/ng/compile.js
Outdated
There was a problem hiding this comment.
Couldn't parentGet be used here (to avoid double parsing) ?
There was a problem hiding this comment.
Do we even need to parse this? We are just passing the string to watch, which parses this anyway. Yeah, I think I was confused about what's going oon in the two-way binding
There was a problem hiding this comment.
I think we should parse it to init the child value. However, you can do this
scope.$watchCollection(parentGet, ...)to not parse twice.
bd1f619 to
ca8cc76
Compare
There was a problem hiding this comment.
Unecessary inject() (here and below) ?
There was a problem hiding this comment.
They are necessary. (many other tests have them). I think it's because the $rootScope etc. "globals" are set up in a module'S return fn.
ca8cc76 to
218b338
Compare
src/ng/compile.js
Outdated
There was a problem hiding this comment.
Are the function names for the watch callbacks swapped?
Should't it be onParentValueChange here and onParentCollectionValueChange above?
218b338 to
93a857b
Compare
93a857b to
31d31e4
Compare
test/ng/compileSpec.js
Outdated
There was a problem hiding this comment.
OOC, what is the purpose of owOptref + owOptreference ?
There was a problem hiding this comment.
Came from a c&p'd test, but owOptreference doesn't look like it's needed.
|
Currently, if an object literal or an array literal is passed as the expression for a two-way ( |
c0b6bdc to
35f5b5b
Compare
There was a problem hiding this comment.
I expected it to remain {name: 'b'}. Interesting...
There was a problem hiding this comment.
Aha, parsed expression with inputs and $$watchDelegates. Nice 😃
There was a problem hiding this comment.
That's why it works? I'm actually confused by this right now.
There was a problem hiding this comment.
Yes. Parsing {name: name} the resulting parsed expression has inputs, so it has a $$watchDelegate that will re-evaluate the expression whenever the inputs change value (in this case, inputs is the name property on $rootScope).
So, whenever $rootScope.name changes, the expression will be evaluated and will return a new object, thus the change will be propagated to the child.
There was a problem hiding this comment.
So this works, but when you are going deeper, you need objectEquality watch - I've added that right now.
No description provided.