-1

I am new to angularjs. Just wanted to know that why does custom attributes which angularjs add to html element doesn't give any error? <div ng-if='true'>

Also, is it possible for us to create our own custom attributes for html elements?

Thanks.

R. Richards
  • 24,603
  • 10
  • 64
  • 64
FIre Panda
  • 6,537
  • 2
  • 25
  • 38
  • Firstly, "custom attributes" as you refer to them are actually `directives`, and the idea in angularjs is that angularjs reads through the DOM tree, looks for these directives, and then rewrites the DOM with whatever added functionality the directives offer. So yes, you can write your own. – Claies Oct 04 '18 at 23:12
  • 1
    Technically, the attributes will cause the initial html to fail w3c validation, and if you are concerned about validation, you should use the `data-` prefix. However, because the HTML isn't meant to be displayed standalone without angularjs, it doesn't actually matter that it doesn't pass strict w3c validation. – Claies Oct 04 '18 at 23:19
  • In other words: because the markup isn't shown as is. It's a template that gets parsed by Angular and translated into the DOM. – Dan Oct 05 '18 at 01:38

1 Answers1

-1

They will not give an error because it is how they should be used and for your question about creating custom attributes I am almost sure that it is impossible