Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567



How to call Jquery function by angular ng-click? – JavaScript – SitePoint Forums

In your controller you’d have something like

$scope.handleClick = function () {
  // jQuery stuff

and in the corresponding template something like

<button id="Edit_Info_Btn" ng-click="handleClick()">Click me</button>

That said (and sorry for repeating myself), I would strongly suggest not to mix AngularJS and jQuery like this; not only is there rarely a point in doing so, but it can likely break your application. A core idea of AngularJS is that you do not have to manipulate the DOM manually; instead, you can solve most things with directives via scope. E.g. something like this

$("#Edit_Info_Btn").on('click', function() {

might look like this the AngularJS way:

// In the controller
$scope.showEditAccount = false

$scope.handleClick = function () {
  $scope.showEditAccount = true
<!-- template -->
<div ng-show="showEditAccount">Some form elements</div>
<button ng-click="handleClick()">Click me</button>

Or even just

<!-- template w/o additional controller logic -->
<div ng-show="showEditAccount">Some form elements</div>
<button ng-click="showEditAccount = true">Click me</button>

If you’re looking for a framework that goes well with jQuery, you might have a look at backbone.js. It’s a bit of a dinosaur among the JS frameworks, but then again, so is AngularJS. :-P

Credit: Source link

Previous Next
Test Caption
Test Description goes like this