Element attributes not mapped with NgAnnotation.TRANSCLUDE_CHILDREN
Attributes declared in map of NgDirectives are ignored if 'children' is set as NgAnnotation.TRANSCLUDE_CHILDREN. E.g.:
Dart code:
@NgDirective(
children: NgAnnotation.TRANSCLUDE_CHILDREN,
selector:'[test-transclude]',
map: const {
'.': '=>dot',
'test': '=>test'
})
class TestTransclude {
TestTransclude(BoundBlockFactory boundBlockFactory,
BlockHole blockHole,
Scope scope);
set dot(value) {
print('set dot: ' + value.toString());
}
set test(value) {
print('set test: ' + value.toString());
}
}
HTML:
<div test-transclude="'fromDot'" test="'fromTest'"></div>
Wrong behaviour: only "set dot" is printed; Expected behaviour: both the set functions should be called.
We wrote a directive that reproduce the NgDirective with transclusion behaviour available in AngularJS; however, we would like to be able to map multiple attributes exactly as in AngularJS. NgComponent is not a good alternative because it uses the shadow dom.
This whole template directive thing needs to be refactored.
Hi Miško, thanks for your answer; however, it does not clarify what should we expect for this issue. Will it be fixed? Or does your answer mean that you plan to add template/templateUrl to the directive?
Yes it will be refactored over the next month or so.
May I ask what this '.': '=>dot', is supposed to do?
@zoechi it maps the value of the element's attribute that matches the selector name, in this case "test-transclude", to a variable named "dot". It is a short cut for 'test-transclude': '=>dot'
Thanks, each day something new! On Feb 19, 2014 8:45 PM, "Francesco" [email protected] wrote:
@zoechi https://github.com/zoechi it maps the value of the element's attribute that matches the selector name, in this case "test-transclude", to a variable named "dot". It is a short cut for 'test-transclude': '=>dot'
— Reply to this email directly or view it on GitHubhttps://github.com/angular/angular.dart/issues/531#issuecomment-35539757 .