I was wondering what is the correct way to integrate jQuery plugins into my angular app. I’ve found several tutorials and screen-casts but they seem catered to a specific plugin.

For Example:

An approach to use jQuery Plugins with AngularJS


http://www.youtube.com/watch?v=8ozyXwLzFYs

Should I create a directive like so –

App.directive('directiveName', function() {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
            $(element).'pluginActivationFunction'(scope.$eval(attrs.directiveName));
        }
    };
}); 

And then in the html call the script and the directive?

<div directiveName ></div>
<script type="text/javascript" src="https://stackoverflow.com/questions/16935095/pluginName.js"></script>

Thanks ahead

2 Answers
2

Leave a Reply

Your email address will not be published. Required fields are marked *