toddmotto / angular-component

Fully featured .component() polyfill for Angular v1.3+
https://toddmotto.com
Other
191 stars 29 forks source link

adding one way binding simulation #15

Closed vanceingalls closed 8 years ago

vanceingalls commented 8 years ago

This article describes a symbol to allow for one way data binding: http://angularjs.blogspot.com/2016/02/angular-150-ennoblement-facilitation.html

Trying this resulted in this issue: https://github.com/toddmotto/angular-component/issues/14

My solution shims this feature by using the '@' notation to simulate one way data binding.

toddmotto commented 8 years ago

Great idea - though I'm just getting a single value rendering from this, if we included this it should mimic the behaviour in the 1.5 stable release.

Component polyfill + your shim: https://jsfiddle.net/toddmotto/ohrnjbn2

Stable release: https://jsfiddle.net/toddmotto/wauana12

They behave quite differently right now :) any thoughts?

vanceingalls commented 8 years ago

ah, right. the data isnt bound in any direction.

vanceingalls commented 8 years ago

how about setting up a watcher within the component then calling the scope value function again to get the new value?

vanceingalls commented 8 years ago

i guess this should be done instead: https://github.com/angular/angular.js/blob/92374f9633d6121b115d77c10248e40e1f4f2aa1/src/ng/compile.js#L3061

mrichard commented 8 years ago

+1 Would be amazing to backfill one way data binding to < 1.5.

thanks!

vanceingalls commented 8 years ago

this solution causes "this" in the controller to evaluate to the window global

toddmotto commented 8 years ago

@mrichard @vanceingalls Can you guys help out? I've just added support for one-way data flow and $onChanges: https://github.com/toddmotto/angular-component/issues/22