• How can web apps be built? – No Framework (raw JS, jQuery or other libraries) – MV* Frameworks (Backbone, Ember, Knockout…) • Why use a framework? • The ‘Angular’ Way • Tonight’s Goal: – Give you the tools to evaluate Angular for future projects 3/27/13 @gcallsen 1
You've either not used it for anything big, have Rain Man-like ability to craft software, or are fucking shitting me. Describing the merits of Ember.js https://gist.github.com/trek/3514718 3/27/13 @gcallsen 2
World Apps • Setup: – Working directory with • ./static/js à jQuery and Angular • ./static/css à main.css and Twitter Bootstrap • ./static/img à Twitter Boostrap 3/27/13 @gcallsen 8 How would you use jQuery to update a div to say “Hello World!”?
• Setup: – Working directory with • ./static/js à jQuery and Angular • ./static/css à main.css and Twitter Bootstrap • ./static/img à Twitter Boostrap 3/27/13 @gcallsen 9 jQuery: • Tag speci"c part of the DOM (ID or Class) • Wait for document to load • Find DOM element, replace with desired text
• Setup: – Working directory with • ./static/js à jQuery and Angular • ./static/css à main.css and Twitter Bootstrap • ./static/img à Twitter Boostrap 3/27/13 @gcallsen 10 jQuery: • Tag speci"c part of the DOM (ID or Class) • Wait for document to load • Find DOM element, replace with desired text Angular: • Bind a variable to a part of the template and de"ne the controller • De"ne value of that variable • Wait for document to load and for Angular to kick in
handle data? • Question: – How do you make User Input update a portion of the page? 3/27/13 @gcallsen 15 • jQuery does not assign user input to any sort of data model • It finds an element’s value and replaces another element’s val • All of this within the scope of the DOM
handle data? • Question: – How do you make User Input update a portion of the page? 3/27/13 @gcallsen 16 • Angular binds user input to the template through a data model • Assigns user input to a data model • Template reflects current value of that data model • (Also faster!) • jQuery does not assign user input to any sort of data model • It finds an element’s value and replaces another element’s val • All of this within the scope of the DOM
user interaction bindings (keyup, change, etc.) or DOM lookups and replacements No ID/Class required (leave that for styling!) Bind data to template. Angular handles DOM updates. 3/27/13 @gcallsen 17
do you currently approach ‘widgets’? – Includes – iFrames – ? • What if you could create your own widget as a tag? 3/27/13 @gcallsen 21 <my-‐new-‐widget> With awesome capabiliLes </my-‐new-‐widget>
do you currently approach ‘widgets’? – Includes – iFrames – ? • What if you could create your own widget as a tag? 3/27/13 @gcallsen 22 <my-‐new-‐widget> With awesome capabiliLes </my-‐new-‐widget> • Example Requirements: • Reusable component • Holiday Spirit! - Custom seasonal greetings for each ‘widget’ • All widgets re#ect the same user input
video tutorials 3/27/13 @gcallsen 32 Gilman Callsen @gcallsen [email protected] Examples from this presentaLon: h-ps://github.com/callseng/angular_v_jquery_1