3

I'm developing an app with Angular2 and since I use directives or custom tags in the code, it can't be validated by W3C HTML validation.

For example if I use <my-component> element or *ngIf directive or some one way/two way binding elements, such as (click) or [(ngModel)], it can't be valid for any W3C validator.

I think I should replace them with elements that are validable.

So, starting from Angular2 documentation, I created the following summary for replacement:

  • (event) --> data-on-event
  • [property] --> data-bind-property
  • [(ngModel)] --> data-bindon-ngModel
  • *ngFor="let i of items" --> data-template="ngFor let i of items"
  • *ngIf="condition" --> data-template="ngIf:condition"

Is this the right way for every element of my list to write code that is compliant with W3C standards?

2
  • Possible duplicate of Angular2 syntax in W3C HTML Validator Commented Nov 29, 2016 at 10:15
  • 1
    That doesn't reply to my interrogative sentence at the end of my post... Commented Nov 29, 2016 at 11:08

1 Answer 1

0

You can "unpack" the *ngFor (and so on) syntactic sugar.

An excellent explanation of this is actually offered in the Tour of Heroes angular 2 tutorial (looking for link...)

Ah found it.

https://angular.io/docs/ts/latest/guide/template-syntax.html#!#star-template

Go to the "* and Template" section.

Sign up to request clarification or add additional context in comments.

2 Comments

Ehm... your link is the link i posted in my question!
Completely nonsense downvote. No explanation and six months after the fact (you should not be allowed to downvote outside of 30 days, another flaw in the SO over-eager downvote system).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.