使用自动关闭标签时不显示AngularJS元素指令 [英] AngularJS element directives not displaying when using self-closing tags

查看:117
本文介绍了使用自动关闭标签时不显示AngularJS元素指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的html文件指令中有

I have in my html file directives

<add />
<back />

和指令在表格上

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

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

这很好.

如果我将指令更改为驼峰式情况:

If i change the directives to camel case:

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

<add_player />
<back />

<add:player />
<back />

显示正常,而

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

仅显示<add-player>,之后的所有内容均不显示.

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

有什么想法吗?

我在这里有同样的行为

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

推荐答案

为了解决您的问题,我引用AngularJS团队的官方声明:(原文如此)

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

html规范定义的

自闭合或void元素对于浏览器解析器而言非常特殊.您无法自己制作,因此对于自定义元素,您必须坚持使用非无效元素(<foo></foo>).

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>).

无法更改角度.

-IgorMinar

- IgorMinar

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

AngularJS问题的页面上进行其余的对话,他们在其中讨论使用XHTML来传递带有浏览器可接受的带有自动关闭标签的内容的可能性.但是请注意,AngularJS不完全支持它.

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.

这篇关于使用自动关闭标签时不显示AngularJS元素指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆