What is the difference between ng-click and data-ng-click in angularjs?

后端 未结 4 1107
囚心锁ツ
囚心锁ツ 2020-12-29 03:01

From 1st view seems like data-ng-click can pass some data as argument to method should be invoked during pressing on button.

But I don\'t see the differ

4条回答
  •  天涯浪人
    2020-12-29 03:46

    From the angular docs on directives:

    Directives have camel cased names such as ngBind. The directive can be invoked by translating the camel case name into snake case with these special characters :, -, or _. Optionally the directive can be prefixed with x-, or data- to make it HTML validator compliant. Here is a list of some of the possible directive names: ng:bind, ng-bind, ng_bind, x-ng-bind and data-ng-bind.

    Leaving them out is totally fine for practical purposes. It's just that if you run it through an html validator service, it will not pass as complliant.

提交回复
热议问题