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

share|improve this question
2  
Did you include jQuery? Your directive would also be implemented as subway-map – tymeJV May 29 '14 at 20:20
    
I use angular in Play 2 framework, and i load jquery pluging with webjar : <script type="text/javascript" src="code.jquery.com/jquery-1.4.2.min.js"></script>; <script type="text/javascript" src="@routes.Assets.at("js/jquery.subwayMap-0.5.0.js")"></sc‌​ript> @Html(org.webjars.play.RequireJS.setup("js/app") – user3689020 May 29 '14 at 20:43
    
I changed directive to subway-map ,it doesn't work – user3689020 May 29 '14 at 20:45
    
Can i see that code on <head></head> – user3001046 Mar 10 '15 at 3:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.