Angular2 HTML5 compliance

68 views
Skip to first unread message

hani

unread,
Apr 5, 2016, 7:13:33 PM4/5/16
to AngularJS
Is there a way not to use or use shorthands for angular2 attributes on html elements? for example, instead of *ngFor use data-ngfor or something like that? is there a way to do something like this?

Günter Zöchbauer

unread,
Apr 6, 2016, 6:19:08 AM4/6/16
to AngularJS
You can use the long form

  • <template ngFor #item [ngForOf]="items" #i="index"><li>...</li></template>

but how is that related to HTML5 compliance? Such markup will be processed by Angular before it is added to the DOM anyway.
The DOM won't ever see any of Angulars *, [], (), or {{}}

Radek Holý

unread,
Apr 6, 2016, 8:09:10 AM4/6/16
to ang...@googlegroups.com

For ngFor I prefer:

    <li template="ngFor #item of items">

and for bindings:

    <div data-bind-title="foo">

and

    <button data-on-click="onClick($event)">

It works in Angular 2.0.0-alpha.45. However, I'm not sure whether it *should* (and will) work since I did not find it in the documentation....

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

 

 

hani

unread,
Apr 6, 2016, 10:59:41 AM4/6/16
to AngularJS
I'm not sure, i can see all those fancy tags in my browser and they seem to be added directly in DOM.

hani

unread,
Apr 6, 2016, 11:32:59 AM4/6/16
to AngularJS, radek...@byzance.cz
Yeah data-on-click seems to work fine, but not the template loop.

Günter Zöchbauer

unread,
Apr 7, 2016, 5:00:00 AM4/7/16
to AngularJS, radek...@byzance.cz
<li template="ngFor #item of items">
you mean ?

  • <template ngFor #item [ngForOf]="items" #i="index"><li>...</li></template>

Günter Zöchbauer

unread,
Apr 7, 2016, 5:00:36 AM4/7/16
to AngularJS
How do you do that? Can you post a screenshot?

Radek Holý

unread,
Apr 7, 2016, 5:35:36 AM4/7/16
to ang...@googlegroups.com

No, I mean:

    <li template="ngFor #item of items; #i = index">...</li>

as documented at https://angular.io/docs/ts/latest/api/common/NgFor-directive.html#syntax

Reply all
Reply to author
Forward
0 new messages