SlideShare a Scribd company logo
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
})
})

More Related Content

PPTX
JavaScript Framework Smackdown
PDF
Building the Front End with AngularJS
PDF
A team 43 C
PPTX
Angular js
PPTX
Prototyping app using JS and HTML5 (Ciklum Kharkiv)
PDF
Frameworks in JavaScript
PPT
Web development today
PPTX
Angular js in your next web application
JavaScript Framework Smackdown
Building the Front End with AngularJS
A team 43 C
Angular js
Prototyping app using JS and HTML5 (Ciklum Kharkiv)
Frameworks in JavaScript
Web development today
Angular js in your next web application

What's hot (20)

PDF
Lesson 09
PPTX
Angular js introduction
PPTX
BlackBerry 10 Browser
PDF
Lesson 09
PPTX
AngularJs advanced Topics
PPTX
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
PDF
Reactjs workshop (1)
PDF
Node.js Jump Start
PPTX
Quick prototyping apps using JS - Ciklum, Vinnitsa
PDF
Mean Stack - An Overview
PPTX
AngularJs Basic Concept
PPT
Unobtrusive javascript
PPTX
Angular js slides
PPTX
Difference between-angular js-nodejs
PPTX
Using jQuery To Survive In ASP.NET Webforms World
PPTX
How to setup aws amplify in a vue project
PPT
Os mobile
PDF
Service Worker 101 (en)
PPTX
Visual regression testing
PPT
Speed Loading
Lesson 09
Angular js introduction
BlackBerry 10 Browser
Lesson 09
AngularJs advanced Topics
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
Reactjs workshop (1)
Node.js Jump Start
Quick prototyping apps using JS - Ciklum, Vinnitsa
Mean Stack - An Overview
AngularJs Basic Concept
Unobtrusive javascript
Angular js slides
Difference between-angular js-nodejs
Using jQuery To Survive In ASP.NET Webforms World
How to setup aws amplify in a vue project
Os mobile
Service Worker 101 (en)
Visual regression testing
Speed Loading
Ad

Similar to Intro to AngularJS (20)

PPTX
Angular Javascript Tutorial with command
PDF
Workshop 12: AngularJS Parte I
PPTX
Introduction to AngularJS Framework
PPTX
Introduction to AngularJS
PDF
Wt unit 5 client &amp; server side framework
PPTX
Valentine with Angular js - Introduction
PPTX
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
PDF
Introduction to AngularJS By Bharat Makwana
PPTX
ANGULARJS introduction components services and directives
PPTX
Introduction to-angular js
DOCX
angularjs_tutorial.docx
PDF
Intro to AngularJS
PPTX
Angular js introduction
PPTX
Angular js
PPTX
Kalp Corporate Angular Js Tutorials
PPTX
Introduction to AngularJS
PPTX
ANGULAR JS TRAINING IN PUNE
PPTX
AngularJS
PPTX
ME vs WEB - AngularJS Fundamentals
PPTX
AngularJS is awesome
Angular Javascript Tutorial with command
Workshop 12: AngularJS Parte I
Introduction to AngularJS Framework
Introduction to AngularJS
Wt unit 5 client &amp; server side framework
Valentine with Angular js - Introduction
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
Introduction to AngularJS By Bharat Makwana
ANGULARJS introduction components services and directives
Introduction to-angular js
angularjs_tutorial.docx
Intro to AngularJS
Angular js introduction
Angular js
Kalp Corporate Angular Js Tutorials
Introduction to AngularJS
ANGULAR JS TRAINING IN PUNE
AngularJS
ME vs WEB - AngularJS Fundamentals
AngularJS is awesome
Ad

More from POSSCON (20)

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

Recently uploaded (20)

PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Modernizing your data center with Dell and AMD
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Approach and Philosophy of On baking technology
PPTX
A Presentation on Artificial Intelligence
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
Reach Out and Touch Someone: Haptics and Empathic Computing
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation_ Review paper, used for researhc scholars
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Modernizing your data center with Dell and AMD
Advanced methodologies resolving dimensionality complications for autism neur...
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Approach and Philosophy of On baking technology
A Presentation on Artificial Intelligence
Building Integrated photovoltaic BIPV_UPV.pdf
Empathic Computing: Creating Shared Understanding
Digital-Transformation-Roadmap-for-Companies.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation theory and applications.pdf
Review of recent advances in non-invasive hemoglobin estimation
Diabetes mellitus diagnosis method based random forest with bat algorithm

Intro to AngularJS