I am new to Angular ,I am a bit confused about how to use a jquery pluging with Angular.
I want to use subway map pluging in my angular app
I create a new directive for subway map :
angular.module('myApp.directives', []).
directive('subwayMap', function() {
return {
// Restrict it to be an attribute in this case
restrict: 'A',
// responsible for registering DOM listeners as well as updating the DOM
link: function(scope, element, attrs) {
angular.element(element).subwayMap({ debug: true });
}
};
});
and a use it in my html page : `
<div subway-Map>
<ul data-color="#EF0010" data-label="jQuery Interactions" data-shiftCoords="0,-1">
<li data-coords="20,14">O</li>
<li data-coords="21,14">P</li>
<li data-coords="22,14">Q</li>
<li data-coords="23,14">R</li>
<li data-coords="24,14">S</li>
</ul>
</div>
but i have an error in subwaymap js :
ReferenceError: jQuery is not defined
})(jQuery);
how to solve this error ?
Thank you for your help
EDIT :
The problem is in directive file, here is my directive file, the appVersion directive works when i remove subwayMap
thanks
/*global define /
'use strict';
define(['angular'], function(angular) {
/ Directives */
angular.module('myApp.directives', []).
directive('appVersion', ['version', function(version) {
return function(scope, elm, attrs) {
elm.text(version);
};
}]);
angular.module('myApp.directives', []).
directive('subwayMap', function() {
return {
// Restrict it to be an attribute in this case
restrict: 'A',
// responsible for registering DOM listeners as well as updating the DOM
link: function(scope, element, attrs) {
angular.element(element).subwayMap({ debug: true });
}
};
});
});
thnks
subway-map
– tymeJV May 29 '14 at 20:20