Soniya Mohan Soniya Mohan - 3 months ago 19
AngularJS Question

Add jQuery dependency in angularJs

How I can add jquery-ui.js to my controller.I'm new to the ui-router

.state('new_patient', {
url: '/newpatient',
templateUrl: window.localStorage.getItem('contextPath') + '/module/laboratory/newpatient',
controller: 'PatientController',
resolve: {
deps: function($q, $rootScope) {
var deferred = $q.defer();
var dependencies = ['jquery-ui'];
require(dependencies, function() {
$rootScope.$apply(function() {
deferred.resolve();
});
});

return deferred.promise;
}
}
});


OR as follows

resolve: { async: ['jquery-ui', function($) {
}]
}


pls help..
Its for working of an accordion.. Thanks in advance for replies.

Answer
.state('new_patient', {
            url: '/newpatient', 
            templateUrl: window.localStorage.getItem('contextPath') + '/module/laboratory/newpatient',
            controller: 'PatientController',
            resolve: {
                deps: function ($q){
                var defer = $q.defer();

                require(['js/core/jquery-ui'], function() {

                        defer.resolve(); 

                });

             return defer.promise;
            }
            }
        });