Angularjs – the difference between ng-click and data-ng-click in angularjs

angularjs

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

I have followed snippets of code:

HTML

<input 
    type="button" 
    value="Fess"
    ng-click="toggle(2)">

OR

<input 
    type="button" 
    value="Fess"
    data-ng-click="toggle(2)">

JS

$scope.toggle = function (valueS) {
    alert(valueS);        
}

Both work.

Thanks,

Best Answer

They are the same thing. You can use data-ng-click to make a valid html.