使用自结束标记时无法显示角元素指令 [英] Angular element directives not displaying when using self-closing tags
问题描述
我在我的HTML文件中的指令
<添加/>
<返回/>
和指令的形式对
.directive('加',['$窗口',...
和
.directive('背',['$窗口',
这工作得很好。
如果我改变指令来骆驼情况:
.directive('addPlayer',['$窗口',...< add_player />
<返回/>
和
<地址:播放器/>
<返回/>
显示效果细腻而
<添加播放器/>定期破折号
<返回/>
只显示<添加播放方式>
和一切后不显示
任何想法,为什么?
编辑:
我种在这里得到了相同的行为
<一个href=\"http://plnkr.co/edit/cpP4c2TyZwv5Y4BrNUBb?p=$p$pview\">http://plnkr.co/edit/cpP4c2TyZwv5Y4BrNUBb?p=$p$pview
要打好你的问题来休息,我引述来自AngularJS队官方声明:(原文如此)
自闭或HTML规范定义它们是非常特殊的浏览器解析无效的元素。你不能让你自己的,所以您的自定义元素,你必须坚持非空元素(
&LT;富&GT;&LT; / foo的&GT;
)
这不能在角被改变。
- IgorMinar
块引用>来源:<一个href=\"https://github.com/angular/angular.js/issues/1953#issuecomment-13135021\">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.这篇关于使用自结束标记时无法显示角元素指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!