且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用自结束标记时无法显示角元素指令

更新时间:2022-11-26 15:26:58

要打好你的问题来休息,我引述来自AngularJS队官方声明:(原文如此)


  

自闭或HTML规范定义它们是非常特殊的浏览器解析无效的元素。你不能让你自​​己的,所以您的自定义元素,你必须坚持非空元素(<富>< / foo的>

。 >
  
  

这不能在角被改变。


  
  

- IgorMinar


块引用>

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

请按照谈话其余在 AngularJS问题的页面,他们讨论使用的可能性 XHTML 交付自动关闭的标签内容是可以接受的浏览器。然而不注意,没有完全由AngularJS支持

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

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.