3

As you know (probably), AngularJS provides ability to create directives based on comments (M).

But why ?

What is the use case ? Any idea ?

One of my students asked me and I was not able to provide any examples... Thanks in advance !

MathKimRobin
  • 1,268
  • 3
  • 21
  • 52

2 Answers2

3

One Use-Case, from the Docs:

Best practice: Comment directives were commonly used in places where the DOM API limits the ability to create directives that spanned multiple elements (e.g. inside <table> elements). AngularJS 1.2 introduces ng-repeat-start and ng-repeat-end as a better solution to this problem. Developers are encouraged to use this over custom comment directives when possible.

— AngularJS Developer Guide - Directive Types

The "M" restriction is used the least often, usually only for backwards compatibility and for passing markup validations.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Founded1898
  • 977
  • 5
  • 13
1

i am thinking of something like ng-if it put a commented html that indicate the place that an element can be inserted if matching criteria, may be it has it's own cases people will use it.

abdoutelb
  • 1,015
  • 1
  • 15
  • 33