Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the...
-
Upload
basil-mcdaniel -
Category
Documents
-
view
214 -
download
0
Transcript of Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the...
![Page 1: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/1.jpg)
Introduction to AngularJames Kahng
![Page 2: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/2.jpg)
Terms
• Framework• Template/environment constructed in the language where you fill in details
with code
• Library• Set of provided functions that do things people often need in their code
![Page 3: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/3.jpg)
Why Angular?
• Single page applications are becoming very popular• Gmail• Google Docs• Trello• Todoist• Others
• BUT HTML, CSS, JS was designed for static websites• Web applications written in these languages can quickly become
complex, unreadable and hack-y
![Page 4: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/4.jpg)
Enter Angular.js
• Released in 2009• Framework that reimagines HTML for web application development• HTML can now communicate with JS code. How does it do this?• Directives
![Page 5: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/5.jpg)
Directives
• Marker (custom attribute) in HTML tag that tells Angular to run some JS code• Demo• The ng-app and ng-controller markers are built-in Angular directives• More later
![Page 6: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/6.jpg)
Expressions
• 2-way data binding• Changes in HTML change our JS variable and vice-versa
• Syntax: {{data}}• Demo
![Page 7: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/7.jpg)
Controllers
• Behavior (Javascript) bound to our H TML• It communicates with the “data model” for our view data• The data you can see
• For example, a controller can hold an array of row entries for a table• Demo
![Page 8: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/8.jpg)
Directives Revisited
• Directives can be used to create reusable DOM elements/attributes/classes• These can add HTML or do some kind of function
• This is how we can produce dynamically rendered pages• Demo• Demo 2
![Page 9: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/9.jpg)
Services
• So far, directives are for DOM manipulation• Controllers are for managing view data• Services are for heavy lifting in the background (application data)• HTTP requests, calculations, storage• Persistent
• Angular has built-in services that include $http, $route• You can also write custom services to better modularize your
application
![Page 10: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/10.jpg)
When to use Angular
• Large-scale dynamic web applications• Scales very well• Organized• Modular and reusable (directives, controllers, services)
• CRUD• Create, Read, Update, Delete
![Page 11: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/11.jpg)
Small-scale?
• Use jQuery and design patterns (Module design pattern)
![Page 12: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/12.jpg)
Rewrite SOONTM
• Angular 2.0 announced (article also explains best practices)• Release ~late 2015-early 2016?• New features and simpler• Will not be backwards-compatible aka your code will break• BUT Learning Angular 1 is great for learning other frameworks and JS
![Page 13: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/13.jpg)
Examples
• Angular Cellar• Cafe Townsend• Angular 2048 (tutorial here)
![Page 14: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/14.jpg)
Resources
Beautiful• Intro video• Part of intro tutorial set (FREE)
• Walkthrough• Explanation of $scope• Incremental examplesNice• Set of tutorial videos
![Page 15: Introduction to Angular James Kahng. Terms Framework Template/environment constructed in the language where you fill in details with code Library Set.](https://reader036.fdocuments.us/reader036/viewer/2022083009/5697bf991a28abf838c91640/html5/thumbnails/15.jpg)
Coding challenge
• Write a simple Angular app using what we learned• Copying is fine, but type it yourself (honor system)• Bear in mind, the most creative app will win• E-mail your entry to [email protected]• May the best man/woman win!