SlideShare uma empresa Scribd logo
1 de 50
Baixar para ler offline
Intro to
AngularJS
POSSCON 2015
WHOAMI
Tom Wilson
● Lead Technologist JRS
● <3 JavaScript
● <3 io.js/node
● <3 couchdb/pouchdb
● <3 angularjs/mercury
Intro to AngularJS
● What is AngularJS
● Why should I use AngularJS?
● How should I get started?
What is AngularJS?
AngularJS is a JavaScript Framework that
abstracts away the direct manipulation of the
DOM using two-way data-binding and
leverages html templates and dependency
injection to create applications.
Why AngularJS
● Simpler code
● Easier manage DRY Code
● Easier to Unit Test
● Flexible Organization
● Easy to integrate with other JS Libs
Desktop
NW.js
Mobile
AngularJS 2
What about angularjs 2?
Getting Started
Install
● Download - https://angularjs.org/
● bower install angular
● npm install angular
Add Script
<html>
<head>...</head>
<body>
<script src=”.../angular.
js”></script>
</body>
</html>
On Tap
● Two-Way Databinding
● HTML Templates
● Controllers
● Services
● Directives
Two-Way Databinding
<body ng-app>
<h1>{{title}}</h1>
<input type=”text” ng-model=”title”>
</body>
http://jsbin.com/verifa/1/edit?html,output
HTML Templates
Compiles HTML5
Template Example
<body ng-app=”App”>
<section ng-controller=”MainCtrl”>
<h2>{{appTitle}}</h2>
<article ng-repeat=”article in articles”>
<header>
<h2>{{article.title}}</h2>
</header>
{{article.body}}
</article>
</section>
</body>
Compile and Link
<body ng-app=”App”>
...
</body>
Built-In
Directives
Built-In Directives
Directives are custom elements, attributes, or
class names that enables declarative coding.
<body ng-app=”myApp”>
</body>
Built-In Directives
ng-app, ng-init, ng-class, ng-model, ng-repeat,
ng-bind, ng-controller, etc
ng-repeat
<body ng-app>
<div ng-init=”list = [1,2,3,4]”></div>
<ul>
<li ng-repeat=”n in list”>{{n}}</li>
</ul>
</body>
http://jsbin.com/sisuku/1/edit?html,output
Controllers
Controllers
<body ng-app=”app”>
<div ng-controller=”
FooCtrl”>
<h1>{{color}}</h1>
</div>
</body>
angular.module('app', [])
.controller('FooCtrl',
function ($scope) {
$scope.color = 'green';
});
http://jsbin.com/qejime/3/edit?html,js
Routing
http://jsbin.com/tanoko/3/edit?output
UI-Router
http://angular-ui.github.io/ui-router/site/#/api/ui.router
ui-router
<nav>
<a ui-sref=”foo”>Foo</a>
<a ui-sref=”bar”>Bar</a>
</nav>
<ui-view></ui-view>
Configuration - $stateProvider
angular.module(‘app’, [])
.config(function($stateProvider,
$urlRouterProvider) {
$stateProvider
.state(‘foo’, {
url: ‘/foo’,
controller: 
,
template: 
,
})
Configuration - $urlRouterProvider
angular.module(‘app’, [])
.config(function($stateProvider,
$urlRouterProvider) {
$urlRouterProvider
.otherwise(‘/’)


})
Views
http://jsbin.com/koreki/2/edit?html,output
Services
http://jsbin.com/yakuti/3/edit?js,output
Custom
Directives
http://jsbin.com/yuhulu/4/edit?html,js
Unit Testing
Unit Testing
// ng-mock
describe(‘foo’, function() {
beforeEach(inject(...))
it(‘bar’, function() {
expect(bam).toEqual(‘bam’)
})
})
Resources
https://github.com/jmcunningham/AngularJS-Learning
Questions
Thank you
Thank You
Extra Info
Modules
Modules
// create module
angular.module(‘app’, [])
<body ng-app=”app”>


</body>
Modules
// reference module
var app = angular.module(‘app’)
Multiple Modules
angular.module(‘foo’, [])
.constant(‘bar’, ‘baz’)
var app = angular.module(‘app’, [‘foo’])
.run(function(bar) { console.log(bar) })
Models
Models
<body ng-app>
<div ng-init=”color = ‘red’”></div>
<h1>{{color}}</h1>
<input type=”text” ng-model=”color”>
</body>
http://jsbin.com/geqede/1/edit?html,output
Filters
http://jsbin.com/qavixu/1/edit?html,output
Filters -
Collections
http://jsbin.com/comisot/1/edit?html,js,output
ng-class
http://jsbin.com/yuhulu/1/edit?html,output
ng-click
http://jsbin.com/zagoxa/2/edit?html,js,output
Forms
http://jsbin.com/naziheduje/1/edit?html,js,output
$http
$http
Is a service to make ajax calls in AngularJS
.controller(‘fooCtrl’, function($scope, $http) {
$http.get(‘/someurl’)
.then(function(res) {
$scope.widgets = res
})
})
$http
Is a service to make ajax calls in AngularJS
.controller(‘fooCtrl’, function($scope, $http) {
$http.post(‘/someurl’, { foo: ‘bar’})
.then(function(res) {
$scope.widgets = res
})
})

Mais conteĂșdo relacionado

Mais procurados

Lesson 09
Lesson 09Lesson 09
Lesson 09
Gene Babon
 
Lesson 09
Lesson 09Lesson 09
Lesson 09
Gene Babon
 
Unobtrusive javascript
Unobtrusive javascriptUnobtrusive javascript
Unobtrusive javascript
Lee Jordan
 

Mais procurados (20)

Lesson 09
Lesson 09Lesson 09
Lesson 09
 
Angular js introduction
Angular js introductionAngular js introduction
Angular js introduction
 
BlackBerry 10 Browser
BlackBerry 10 BrowserBlackBerry 10 Browser
BlackBerry 10 Browser
 
Lesson 09
Lesson 09Lesson 09
Lesson 09
 
AngularJs advanced Topics
AngularJs advanced TopicsAngularJs advanced Topics
AngularJs advanced Topics
 
JS Fest 2019/Autumn. ВлаЎ Đ€Đ”ĐŽĐŸŃĐŸĐČ. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. ВлаЎ Đ€Đ”ĐŽĐŸŃĐŸĐČ. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. ВлаЎ Đ€Đ”ĐŽĐŸŃĐŸĐČ. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. ВлаЎ Đ€Đ”ĐŽĐŸŃĐŸĐČ. Technology agnostic microservices at SPA f...
 
Reactjs workshop (1)
Reactjs workshop (1)Reactjs workshop (1)
Reactjs workshop (1)
 
Node.js Jump Start
Node.js Jump StartNode.js Jump Start
Node.js Jump Start
 
Quick prototyping apps using JS - Ciklum, Vinnitsa
Quick prototyping apps using JS - Ciklum, VinnitsaQuick prototyping apps using JS - Ciklum, Vinnitsa
Quick prototyping apps using JS - Ciklum, Vinnitsa
 
Mean Stack - An Overview
Mean Stack - An OverviewMean Stack - An Overview
Mean Stack - An Overview
 
AngularJs Basic Concept
AngularJs Basic ConceptAngularJs Basic Concept
AngularJs Basic Concept
 
Unobtrusive javascript
Unobtrusive javascriptUnobtrusive javascript
Unobtrusive javascript
 
Angular js slides
Angular js slidesAngular js slides
Angular js slides
 
Difference between-angular js-nodejs
Difference between-angular js-nodejsDifference between-angular js-nodejs
Difference between-angular js-nodejs
 
Using jQuery To Survive In ASP.NET Webforms World
Using jQuery To Survive In ASP.NET Webforms WorldUsing jQuery To Survive In ASP.NET Webforms World
Using jQuery To Survive In ASP.NET Webforms World
 
How to setup aws amplify in a vue project
How to setup aws amplify  in a vue projectHow to setup aws amplify  in a vue project
How to setup aws amplify in a vue project
 
Os mobile
Os mobileOs mobile
Os mobile
 
Service Worker 101 (en)
Service Worker 101 (en)Service Worker 101 (en)
Service Worker 101 (en)
 
Visual regression testing
Visual regression testingVisual regression testing
Visual regression testing
 
Speed Loading
Speed LoadingSpeed Loading
Speed Loading
 

Semelhante a Intro to AngularJS

Semelhante a Intro to AngularJS (20)

Angular Js
Angular JsAngular Js
Angular Js
 
Anjular js
Anjular jsAnjular js
Anjular js
 
What are the key distinctions between Angular and AngularJS?
What are the key distinctions between Angular and AngularJS?What are the key distinctions between Angular and AngularJS?
What are the key distinctions between Angular and AngularJS?
 
AngularJS – What, Why, Advantages and Disadvantages
AngularJS – What, Why, Advantages and DisadvantagesAngularJS – What, Why, Advantages and Disadvantages
AngularJS – What, Why, Advantages and Disadvantages
 
AngularJS – What, Why, Advantages and Disadvantages
AngularJS – What, Why, Advantages and DisadvantagesAngularJS – What, Why, Advantages and Disadvantages
AngularJS – What, Why, Advantages and Disadvantages
 
Angularjs on line training
Angularjs on line trainingAngularjs on line training
Angularjs on line training
 
Play with Angular JS
Play with Angular JSPlay with Angular JS
Play with Angular JS
 
Tips on How to Optimize AngularJS App Performance
Tips on How to Optimize AngularJS App PerformanceTips on How to Optimize AngularJS App Performance
Tips on How to Optimize AngularJS App Performance
 
Introduction to AngularJS Framework
Introduction to AngularJS FrameworkIntroduction to AngularJS Framework
Introduction to AngularJS Framework
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
 
Introduction to AngularJS By Bharat Makwana
Introduction to AngularJS By Bharat MakwanaIntroduction to AngularJS By Bharat Makwana
Introduction to AngularJS By Bharat Makwana
 
angularjs_tutorial.docx
angularjs_tutorial.docxangularjs_tutorial.docx
angularjs_tutorial.docx
 
angularjs_vs_angular_the_key_differences_between_javascript_and_typescript.pptx
angularjs_vs_angular_the_key_differences_between_javascript_and_typescript.pptxangularjs_vs_angular_the_key_differences_between_javascript_and_typescript.pptx
angularjs_vs_angular_the_key_differences_between_javascript_and_typescript.pptx
 
Angular js
Angular jsAngular js
Angular js
 
Top Reasons to Choose AngularJS as your Front-end Framework
Top Reasons to Choose AngularJS as your Front-end FrameworkTop Reasons to Choose AngularJS as your Front-end Framework
Top Reasons to Choose AngularJS as your Front-end Framework
 
AngularJs
AngularJsAngularJs
AngularJs
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01
 
7 effective reasons why you should use angular js for mobile app development
7 effective reasons why you should use angular js for mobile app development7 effective reasons why you should use angular js for mobile app development
7 effective reasons why you should use angular js for mobile app development
 

Mais de POSSCON

Mais de POSSCON (20)

Why Meteor.JS?
Why Meteor.JS?Why Meteor.JS?
Why Meteor.JS?
 
Vagrant 101
Vagrant 101Vagrant 101
Vagrant 101
 
Tools for Open Source Systems Administration
Tools for Open Source Systems AdministrationTools for Open Source Systems Administration
Tools for Open Source Systems Administration
 
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
 
Accelerating Application Delivery with OpenShift
Accelerating Application Delivery with OpenShiftAccelerating Application Delivery with OpenShift
Accelerating Application Delivery with OpenShift
 
Openstack 101
Openstack 101Openstack 101
Openstack 101
 
Community Building: The Open Source Way
Community Building: The Open Source WayCommunity Building: The Open Source Way
Community Building: The Open Source Way
 
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP AnywayI Know It Was MEAN, But I Cut the Cord to LAMP Anyway
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
 
Software Defined Networking (SDN) for the Datacenter
Software Defined Networking (SDN) for the DatacenterSoftware Defined Networking (SDN) for the Datacenter
Software Defined Networking (SDN) for the Datacenter
 
Application Security on a Dime: A Practical Guide to Using Functional Open So...
Application Security on a Dime: A Practical Guide to Using Functional Open So...Application Security on a Dime: A Practical Guide to Using Functional Open So...
Application Security on a Dime: A Practical Guide to Using Functional Open So...
 
Why Your Open Source Story Matters
Why Your Open Source Story MattersWhy Your Open Source Story Matters
Why Your Open Source Story Matters
 
How YARN Enables Multiple Data Processing Engines in Hadoop
How YARN Enables Multiple Data Processing Engines in HadoopHow YARN Enables Multiple Data Processing Engines in Hadoop
How YARN Enables Multiple Data Processing Engines in Hadoop
 
Google Summer of Code
Google Summer of CodeGoogle Summer of Code
Google Summer of Code
 
Introduction to Hadoop
Introduction to HadoopIntroduction to Hadoop
Introduction to Hadoop
 
How to Use Cryptography Properly: The Common Mistakes People Make When Using ...
How to Use Cryptography Properly: The Common Mistakes People Make When Using ...How to Use Cryptography Properly: The Common Mistakes People Make When Using ...
How to Use Cryptography Properly: The Common Mistakes People Make When Using ...
 
Cyber Security and Open Source
Cyber Security and Open SourceCyber Security and Open Source
Cyber Security and Open Source
 
Docker 101: An Introduction
Docker 101: An IntroductionDocker 101: An Introduction
Docker 101: An Introduction
 
Graph the Planet!
Graph the Planet!Graph the Planet!
Graph the Planet!
 
Software Freedom Licensing: What You Must Know
Software Freedom Licensing: What You Must KnowSoftware Freedom Licensing: What You Must Know
Software Freedom Licensing: What You Must Know
 
Contributing to an Open Source Project 101
Contributing to an Open Source Project 101Contributing to an Open Source Project 101
Contributing to an Open Source Project 101
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Christopher Logan Kennedy
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls đŸ„° 8617370543 Service Offer VIP Hot Model
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Intro to AngularJS