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

Commit 9868db2

Browse files
committed
Fixes #45 - When using $map mode '=' the value should be available in the scope right away
1 parent 4713002 commit 9868db2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/block.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ class ComponentFactory {
322322
shadowScope[attrName] = attrValue;
323323
} else if (mapping == '=') {
324324
ParsedFn expr = parser(attrValue);
325-
var shadowValue;
325+
var shadowValue = expr(parentScope);
326+
shadowScope[attrName] = shadowValue;
326327
shadowScope.$watch(
327328
() => expr(parentScope),
328329
(v) => shadowScope[attrName] = shadowValue = v);

test/compiler_spec.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,18 @@ main() {
456456
expect($rootScope.done).toEqual(true);
457457
}));
458458

459+
it('should create a component with IO and "=" binding value should be available', inject(() {
460+
$rootScope.name = 'misko';
461+
var element = $(r'<div><io attr="A" expr="name" ondone="done=true"></io></div>');
462+
$compile(element)(injector, element);
463+
var component = $rootScope.ioComponent;
464+
expect(component.scope.expr).toEqual('misko');
465+
$rootScope.$apply();
466+
component.scope.expr = 'angular';
467+
$rootScope.$apply();
468+
expect($rootScope.name).toEqual('angular');
469+
}));
470+
459471
it('should expose mapped attributes as camel case', inject(() {
460472
var element = $('<camel-case-map camel-case=6></camel-case-map>');
461473
$compile(element)(injector, element);

0 commit comments

Comments
 (0)