This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
@NgAttr bind statements cannot contain dashes if compiling to JS #1576
Open
Description
In Dart, if I have an @Ngattr on a field where the attribute name contains a dash, the binding will not work correctly.
Example:
@Ngattr('foo-bar')
someVariable
will not work when we do bind-foo-far="bindingVariable"
However, simply changing it to @Ngattr('foo') and bind-foo="bindingVariable" makes things work. Note that this error only happens when the Dart code is compiled to JavaScript, so it may be a dart2js issue. The obfuscated error for the above example will be o.someVariable no getter someVariable for o.
Activity
jbdeboer commentedon Oct 24, 2014
bind-foo-far should map to @Ngattr('fooFar');
attributes are case insensetive, so we had to choose between camelCase and snake-case. Since bind- is intended for property binding, and 'foo-bar' is not a valid Dart or JS property name, we prefer camelCase.
bernardyen commentedon Oct 24, 2014
Thanks for the clarification. However, in the AngularDart documentation at
https://angulardart.org/tutorial/05-ch03-component.html, it gives an
example where we should be able to bind using a hyphen. Can you please
update the documentation and explicitly say that hyphenated variables are
not supported in the dart2js conversion?
For reference, running it as native dart code in Dartium works fine.
On Fri, Oct 24, 2014 at 11:32 AM, James deBoer notifications@github.com
wrote:
naomiblack commentedon Dec 9, 2014
@vicb can you take a look into this please?
vicb commentedon Dec 10, 2014
@bernardyen Could you provide a snippet which show the issue, I can not re-produce it.
Also by looking at the code I can't not explain why it would fail and why the behavior would be different in JS vs Dart.
Edit: what version of angular.dart do you use ?
bernardyen commentedon Dec 10, 2014
Victor,
I'm adding Ted, who knows more about the compilation from Dart -> JS for
our application. I don't think I can provide a snippet, but basically if we
change the combination of @Ngattr('xxx') and bind-xxx to @NgOneWay and xxx,
the problem goes away.
akberali67 commentedon Aug 26, 2016
I am having the same issue, ng-attr does not seem to accept a tag with a dash in it, here is an example below:
I did try to plug the ng-attr with the same value to the