【发布时间】:2013-11-03 06:40:10
【问题描述】:
有时我看到data-ng-controller,但更多时候看到ng-controller
ng-controller 我已经用过,这似乎很清楚。但是data-ng-controller.. 有什么用?
它们之间有什么区别,在哪里使用什么?
【问题讨论】:
标签: angularjs
有时我看到data-ng-controller,但更多时候看到ng-controller
ng-controller 我已经用过,这似乎很清楚。但是data-ng-controller.. 有什么用?
它们之间有什么区别,在哪里使用什么?
【问题讨论】:
标签: angularjs
除了验证和浏览器兼容性之外没有区别。
Angular js 不能在 IE8 中工作,除非数据存在
[更新]
【讨论】:
Angularjs 使用规范化过程来匹配指令名称/属性。
来自 http://docs.angularjs.org/guide/directive 的 angularjs 文档。
部分匹配指令:
归一化过程如下:
从元素/属性的前面去除 x- 和 data-。 将 :、- 或 _ 分隔的名称转换为 camelCase。
【讨论】:
两者之间没有区别,除了前缀data-将允许HTML通过验证。
【讨论】:
您可能还会看到 x-ng-controller。 data- 和 x- 都符合 html5 自定义属性命名。
【讨论】: