Friday, 15 February 2013

Injecting jquery events/functions into angularjs -


I currently have a block of code:

  $ ('.btn') Click (function () ($ (this) .removeClass ('big-red button'); $ (this) .addClass ('btn-loading'); $ (this). Find ('.text' Text ('Working ..'); $ (this) .Find ('.State') AddClass ('Load'); $ (this) .Find ('I'). ReplaceWith ('& lt; img Src = "/   

});

This is when the button is clicked when this button changes the CSS, it disables it And sets the text in "Working ..", that is the sub The yogi knows that a verb is being executed, I know that there are other ways to do this but I like this way. My problem is now that I am using Angelise and I am using NG- Clicking which executes a function, now before that function I starts to execute the jquery code above and when the function is complete I change the same jquery code I want to edit

  $ scope.addTicket = function (ticket, schedule_id) {// set button to work in state // put stuff here // set button in full condition;} ;  

Now if I was using jquery alone I would be able to do this, but now I do not know how to work with my jquery code angular.

You will see the instructions as below, and then we will remove the ng-click method.

Markup

  & lt; Button my-directive add-ticket = "addTicket ()" & gt; & Lt; / Button & gt;  DirectX   (Element, element, etter) element {element.on ('click', function) (element.removeClass ('big red button'); element.addClass ('btn-loading'); element.find ('.text (' Workin '.'); Element.find ('state') AddClass ('load'); element.find ('i'). Replacewith ('& lt; img src = "/ images / loadinging.gif"> ; '+' & Lt; / img & gt; '); Scope. $ Apply (attrs.addTicket);});}});  

No comments:

Post a Comment