Skip to content
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
@bernardyen

Description

@bernardyen

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

jbdeboer commented on Oct 24, 2014

@jbdeboer
Contributor

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

bernardyen commented on Oct 24, 2014

@bernardyen
Author

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:

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.


Reply to this email directly or view it on GitHub
#1576 (comment)
.

naomiblack

naomiblack commented on Dec 9, 2014

@naomiblack
Contributor

@vicb can you take a look into this please?

vicb

vicb commented on Dec 10, 2014

@vicb
Contributor

@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

bernardyen commented on Dec 10, 2014

@bernardyen
Author

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

akberali67 commented on Aug 26, 2016

@akberali67

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

above with the width attribute and that worked perfectly meaning data is getting imported in the controller and html, it is just this tag that does not seem to be working,

                  <div class="col-md-12 col-sm-12 col-xs-6" ng-controller="HomeCtrl">
                    <div>
                      <p>HomeGuru</p>
                      <div class="">
                        <div class="progress progress_sm" style="width: 100%;">
                          <div class="progress-bar bg-green" role="progressbar" ng-attr-data-transitiongoal="{{totalhga | number:0}}"></div>
                        </div>
                      </div>
                    </div>
                    <div>
                      <p>OzHomeValue</p>
                      <div class="">
                        <div class="progress progress_sm" style="width: 100%;">
                          <div class="progress-bar bg-green" role="progressbar" ng-attr-data-transitiongoal="{{totalohva || undefined}}"></div>
                        </div>
                      </div>
                    </div>
                  </div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @vicb@jbdeboer@naomiblack@akberali67@bernardyen

        Issue actions

          @NgAttr bind statements cannot contain dashes if compiling to JS · Issue #1576 · dart-archive/angular.dart