Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS element directives not displaying when using self-closing tags

Tags:

I have in my html file directives

<add /> <back /> 

and the directives are on the form

.directive('add', ['$window', ... 

and

.directive('back', ['$window',  

This works fine.

If i change the directives to camel case:

.directive('addPlayer', ['$window', ...  <add_player /> <back /> 

and

<add:player /> <back /> 

display fine whereas

<add-player />  regular dash <back /> 

displays only <add-player> and everything after is not displayed.

Any ideas why?

EDIT:

I've kind of gotten the same behaviour here

http://plnkr.co/edit/cpP4c2TyZwv5Y4BrNUBb?p=preview

like image 700
Hawk Avatar asked Aug 07 '13 12:08

Hawk


People also ask

How do you write a self closing HTML element?

The br tag inserts a line break (not a paragraph break). This tag has no content, so it is self closing.

Does HTML support self closing tags?

What Does Self-Closing Tag Mean? A self-closing tag is an element of HTML code that has evolved in the language. Typically, the self-closing tag makes use of a “/” character in order to effectively close out a beginning tag enclosed in sideways carets.

Which of the following tags is not self closing?

You need not close it as it is an empty tag. It only has attributes but no content. which of the following is not a self closing tag? <em> is not a self closing tag, em tag is used for emphasis content.

Is embedded tag is a self closing tag?

The HTML <embed> tag is used for embedding an external application or interactive content into an HTML document. Note that the <embed> element is an empty element (no closing tag is used).


1 Answers

To lay your question to rest, I am quoting the official statement from the AngularJS team: (sic)

self-closing or void elements as the html spec defines them are very special to the browser parser. you can't make your own, so for your custom elements you have to stick to non-void elements (<foo></foo>).

this can't be changed in angular.

- IgorMinar

source: https://github.com/angular/angular.js/issues/1953#issuecomment-13135021

Follow the rest of the conversation on AngularJS issue's page where they discuss the possibility of using XHTML for delivering content with self-closing tags that is acceptable to the browser. However do note that it is not fully supported by AngularJS.

like image 130
bPratik Avatar answered Sep 21 '22 18:09

bPratik