Gerald Mathabela Gerald Mathabela - 4 years ago 123
jQuery Question

How to call a JQuery event within AngularJS function

Assuming validation is successful, how do i then call this Jquery event...

$('#login').click(function() {
//blah blah blah...

From this AngularJS function

// create angular app
var validationApp = angular.module('validationApp', []);

// create angular controller
validationApp.controller('mainController', function($scope) {

// function to submit the form after all validation has occurred
$scope.submitForm = function() {

// check to make sure the form is completely valid
if ($scope.userForm.$valid) {
// Call my Jquery function here



Answer Source

jQuery and AngularJS can work together but it is not good practice. You could use the built-in AngularJS ng-click to fire the onClick event and apply a function to it as follows:

<div id="login" ng-click="loginScriptToRunOnClick()"> My Login Div </div>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download