NG-应用与数据-NG-应用程序,有什么区别? [英] ng-app vs. data-ng-app, what is the difference?
问题描述
目前我在看本入门教程视频为 angular.js
在某一时刻(12'40后),发言者指出,属性 NG-应用
和数据-NG-应用=
是在&LT更多或等值以下; HTML>
标记等等都 NG-模式=my_data_binding
和数据-NG-模式=my_data_binding
。然而,讲话者说的HTML将通过不同的验证器进行验证,这取决于所使用的属性。
At some moment (after 12'40"), the speaker states that the attributes ng-app
and data-ng-app=""
are more or less equivalent inside the <html>
tag, and so are ng-model="my_data_binding
and data-ng-model="my_data_binding"
. However The speaker says the html would be validated through different validators, depending on which attribute is used.
您能解释一下这两种方式之间的差异,纳克 -
preFIX对数据纳克 -
preFIX?
Could you explain the difference between the two ways, ng-
prefix against data-ng-
prefix ?
推荐答案
好问题。所不同的是简单的 - 是绝对没有,除了某些HTML5校验器将在属性上抛出一个错误,如 NG-应用
两个之间的区别,但他们不扔任何东西prefixed的误差数据 -
,如数据-NG-应用
Good question. The difference is simple - there is absolutely no difference between the two except that certain HTML5 validators will throw an error on a property like ng-app
, but they don't throw an error for anything prefixed with data-
, like data-ng-app
.
因此,要回答你的问题,使用数据-NG-应用
如果您想验证你的HTML是一个更容易一些。
So to answer your question, use data-ng-app
if you would like validating your HTML to be a bit easier.
有趣的事实:你也可以使用 X-NG-应用
同样的效果。
Fun fact: You can also use x-ng-app
to the same effect.
这篇关于NG-应用与数据-NG-应用程序,有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!