I am working on one small angularjs app. I have a button, where I am using 2 events, ng-click, and onlick. It works right and there are no issues, but I want to be sure 100% I am doing it good and is my approach right ? Is it allowed to have them together at a button state events ?
You can bind as many events as you wish to a button etc. But this is superfluous. See this jsFiddle: Bind events
JS:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.ngFn = function () {
console.log("ngFn is triggered!");
};
}
function nativeFn() {
console.log("nativeFn is triggered!");
};
$(document).ready(function() {
$('#forJq').bind('click', function () {
console.log("Anonymous function bind by jq is triggered!");
});
});
HTML:
<div ng-controller="MyCtrl">
<button id="forJq" onclick="nativeFn()" ng-click="ngFn()">Try me!</button>
</div>