I think all of your questions can be answered with this one reply. AngularJS takes the view that HTML was not designed for building Web applications, but it should have been. So AngularJS makes it that way with directives like ng-click. AngularJS rejects the idea that HTML markup should be minimal and pages should be made dynamic through explicit DOM manipulation. In most cases directives replace the need for explicit DOM manipulation. For almost anything you want to do that you think requires DOM manipulation in JavaScript code, someone will show you how it can be done using provided or custom directives.
On Mon, Feb 24, 2014 at 9:48 AM, KDart <[email protected]> wrote: > I'm sure this is asked a heck of a lot of times - but I hope this question > is fairly unique in what jQuery has aided me with/taught me. > > 1) When learning jQuery I was always told to separate logic from content - > and the worst way to defy this rule is to assign the onclick event inline - > i.e.: > <a id="myFuncHandler" href="#" onclick="myFunction('some var')">My > Function!</a> > > Which I understand is a horrendous way of doing it. Instead, to use jQuery > as follows: > > $('#myFuncHandler').on('click', function (e) { > myFunction(/*Here you can pass any type to the function, even an > object*/); > }); > > Which obviously has so many more added benefits! It means I can assign > dynamic objects to my click handler, instead of just text/numbers as > supported in HTML. > > So, why does AngularJS reintroduce the concept of ng-click? This seems > backwards to me? > > 2) I use jQuery to build a lot of dynamic content - and so (coming from a > C# background) jQuery allows me to resemble C# code a lot - and so I'm much > more comfortable doing this. > > Particularly, one part of my app (which is server driven) will generate a > control based on some data it has received from the server (from parsed > JSON) and builds this, and appends it to the DOM. > > In fact, quite a bit of our app uses this mechanism because of the nature > of our app. Our HTML document will be next to empty, and when it receives > info from the server (which, say, reads "SELECT" then the app will build a > <select> control using jQuery, a small example as follows: > > > $('<select>').append($('<option>1</option><option>2</option><option>3</option>')).appendTo('body'); > > Which builds a very simple select (obviously the app does more). I have no > idea how I can do this in AngularJS? Is it even possible? > > 3) As part of (2) - the app I am developing builds multiple jQuery Mobile > pages and appends those to the DOM, each with their unique content on every > page (again, which is obtained from a complex JSON feed) - is *this* possible > with AngularJS? > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/groups/opt_out. > -- R. Mark Volkmann Object Computing, Inc. -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/groups/opt_out.
