Quantcast
Channel: User Chamilyan - Stack Overflow
Viewing all articles
Browse latest Browse all 43

Answer by Chamilyan for Should we use jQuery with AngularJS?

$
0
0

Here is a good way to approach it. If you want to mix jQuery with Angular.. write directives in AngularJS and in the link section of those directives you can include jQuery for DOM manipulation.

Keep in mind that AngularJS uses jQuery lite so a lot of what jQuery does is already built into Angular.

For example you can use jQuery lite in angular like this anywhere in an angular app:

angular.element('.class').append('<p>foo</p>');

and inside of a directive link function,

angular.module('TestModule').directive('jqueryTestDirective', ['$timeout', function($timeout) {    return {      restrict: 'E',      link : function (scope, element) {        $timeout(function(){             element.append('<p>foo</p>');        });      }}]);<jquery-test-directive></jquery-test-directive>

Viewing all articles
Browse latest Browse all 43

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>