Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Fixes #45 - When using $map mode '=' the value should be available in the scope right away #46

Merged
merged 1 commit into from
Jul 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ class ComponentFactory {
shadowScope[attrName] = attrValue;
} else if (mapping == '=') {
ParsedFn expr = parser(attrValue);
var shadowValue;
var shadowValue = expr(parentScope);
shadowScope[attrName] = shadowValue;
shadowScope.$watch(
() => expr(parentScope),
(v) => shadowScope[attrName] = shadowValue = v);
Expand Down
12 changes: 12 additions & 0 deletions test/compiler_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,18 @@ main() {
expect($rootScope.done).toEqual(true);
}));

it('should create a component with IO and "=" binding value should be available', inject(() {
$rootScope.name = 'misko';
var element = $(r'<div><io attr="A" expr="name" ondone="done=true"></io></div>');
$compile(element)(injector, element);
var component = $rootScope.ioComponent;
expect(component.scope.expr).toEqual('misko');
$rootScope.$apply();
component.scope.expr = 'angular';
$rootScope.$apply();
expect($rootScope.name).toEqual('angular');
}));

it('should expose mapped attributes as camel case', inject(() {
var element = $('<camel-case-map camel-case=6></camel-case-map>');
$compile(element)(injector, element);
Expand Down