1

Is there a library available that can basically take any jquery ui component and turn it into an angularjs directive, with zero configuration required on my part?

In other words, I'm looking for a way to get lots of neat angularjs ui directives "for free".

1
  • 1
    I doubt it, angular and jQuery have different ways of going about things, jQuery directly manipulates the DOM and depends on looking for particular elements across the DOM to make manipulations. I don't think this is a deficiency of jQuery itself per se but more the widespread untrained masses using it. AngularUI has been very useful for me otherwise I've just found github projects so far to serve my purposes. angular-ui.github.io A specific UI component type you're missing would help. Commented Aug 2, 2013 at 17:22

2 Answers 2

3

Why dont you use them as an Angular Service?

I needed to use jQuery Carousel inside my Angular Controller. So I created an app called Animation to host my AnimationService like this

app.js:

'use strict';

var animation = angular.module('animation', []);

service.js:

animation.service('AnimationService', function($timeout) {

    this.carousel = function(element, options) {
        $(element).tinycarousel(options);
    };

});

After that I just need to inject on my angular app:

app.js:

var myApp = angular.module('myApp', ['animation']);

Inject on my angular Controller:

myApp.controller('MyCtrl', function ($scope, $http, AnimationService) {

});

Finally I call the carousel like this (inside my controller):

AnimationService.carousel('.slider', { pager: true });

The first parameter is the element and the second is the jquery.carousel options.

Hope this could help. Let me know if you need any further explanations or examples

Sign up to request clarification or add additional context in comments.

2 Comments

This is an awesome answer awesomely written but it does not answer the question about Directives. Gj anyway!
He could use the service on his directive file. But I didn't read the "with zero configuration required on my part" thing. So I guess my answer is wrong and I don't think there's a way to do that :(
0

Late answer here, but the angular-ui project has a directive called "jQuery Passthrough" which lets you call a jquery function pretty easily from Angular. I've used it a handful of times and for me it has worked great.

I don't think this isn't specifically what you asked for, but if the goal is to easily hook into some jQuery code from Angular without having to write your own directive then this works pretty well. Good luck.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.