SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Intro to 
AngularJS 
Overview on AngularJS 1.3 & Angular UI
About AngularJS 
The Basics
What is AngularJS? 
● AngularJS is an MVC framework for web apps, 
allowing devs to use only HTML, CSS, and JavaScript 
on the front-end. 
● It is maintained and supported by Google 
● Searches for AngularJS have shot up over the past 
year, indicating that it's the next big thing in the JS 
and front-end world 
● Alternatives: Knockout, Ember, Backbone
Why Angular? 
● Create custom HTML elements through directives, allowing further 
manipulation of the DOM 
o ex: Tags <dropdown></dropdown> can be used for a custom dropdown, 
pulling from a template.html file for a reusable dropdown 
● Layered on top of jQlite instead of jQuery - lighter weight code and less lines of 
code for faster, more efficient load 
● Flexible - Angular puts you in control of HTML elements and how it interfaces 
with JS and the back end 
● HTML5 Hybrid Mobile Apps can be built using AngularJS 
● Modular, meaning that it’s more geared towards modules of code that you can 
save in one file and reuse again and again throughout your app
Basic Components of Angular 
● Expressions - One of the most basic components of Angular. Expressions allow you to 
evaluate calculations or variables and print data on the view. They are typically 
surrounded by double curly braces {{5 + 5}}, though you can also use ng-bind 
● Directives - Allow you to extend native HTML elements and write your own HTML tags 
and attributes. With directives, you can create a descriptive tag for easier, faster 
readability and store a regularly used piece of code in one file. 
● Controllers - JavaScript functions that allow you to access and manipulate data. You can 
have one controller per page or multiple controllers for separate sections of the page. 
● Views - The templates used for your web pages. 
● Scope - Context where data & values are stored so that all components have access to it. 
This is how you can display data on your views and send data from user input on your 
view. 
● Filters - JavaScript functions that format data. Angular ships with several built-in filters, 
such as date, limitTo, orderBy, and currency
Basic Components of Angular (cont.) 
● Factories and Services - JavaScript code that is independent of controllers and views. 
Typically, these are functions that return data to share among different sections of your 
app. 
● Modules - The components of your Angular app, such as directives, controllers, and 
services. However, modules can also be thought of as different sections of your app 
separated out for improved readability and organization. 
● Dependency Injection - The way that an Angular controller is made aware of a service or 
factory that will be used.
Native Routing w/ AngularJS 
● Uses the $locationProvider service for the configuration module 
● To use, must inject ngRoute service into your angular module (i.e., 
angular.module(‘myApp’, [‘ngRoute’]) 
● Routes are one level deep, meaning that you can have /client={{clientId}} but not 
/client/{{clientId}} 
● View is loaded into the ng-view directive: <ng-view></ng-view> 
● Links are determined by what mode you’re running your app in: 
o Hashbang mode is the default for Angular. This appends a hash symbol to your 
routes: <a href=“#/home”>Home</a> or <a href=“#!/home”>Home</a>. Using a 
suffix (such as the ! symbol) is good for SEO. 
o HTML5 mode prettifies your URIs: <a href=“/home”>Home</a> 
o For SEO purposes, you may need to run a headless WebKit scriptable such as 
PhantomJS 
● To access your $route options and parameters in your controllers, you can pass in these 
services: $route, $routeParams, and $location
Example of Native Routing w/ AngularJS 
angular.module('MyApp', ['ngRoute', 'ngResource']) 
.config(function($routeProvider, $locationProvider) { 
$routeProvider 
.when('/', { 
templateUrl:'home.html', 
controller: 'HomeCtrl' 
}) 
.when('/user-id=:id, { 
templateUrl: user_profile.html', 
controller: 'UserProfileCtrl' 
}) 
})
Generating Angular Files 
Simple: Include a link to the Angular library in the head of your HTML 
and set up the JS file and declare ng-app yourself. 
Advanced: Use an NPM package to scaffold a local development 
environment along with the basic files necessary for an Angular 
app. I use Yeoman.io, which packages Yo, Bower, and Grunt. 
Yo - Automagically generates common files (like Bootstrap CSS files and JS 
libraries like Angular) 
Bower - Dependency Management (This means you can pull files and packages 
from github, like Angular UI, and automatically declare them as dependent 
packages in your angular app so angular “sees” them) 
Grunt - Server, Testing, and Automated Task Running (unit tests, minification, 
compilation)
Scope 
Accessing from the controller and view
A Word on Scope 
● Scope is used to determine where a variable will be 
accessible in your app. 
● In Angular, each controller creates its own scope, meaning a 
scope variable is only good in that controller or child 
controllers 
● Some views can have multiple controllers or multiple scopes 
- you can access a variable across scopes using $rootScope 
o Note: The “Angular way” to share a variable or piece of 
data across controllers is actually to use factories and 
services
A Word on Scope (cont) 
● When you declare a variable in your controller, you can use a 
local variable only viewable by the controller (var testVar) or 
a $scope variable, which the front end can display 
($scope.testVar) 
● To display $scope variables, use double curly braces in your 
HTML ({{}}) or use ng-bind (<span ng-bind=” 
testVar”></span> 
● Some devs prefer ng-bind because of a “blink and flash” - 
this can also be solved by preventing the page from loading 
before the data comes in
Two Way Binding 
Angular does something cool with $scope variables - two way binding.This means that every 
instance of a variable is updated as the value is manipulated - in other words, updating one 
triggers a refresh of the DOM. Example: 
<h1>Hello, {{contact.name}}!</h1> 
<input type=“text” ng-model=“contact.name” /> 
The above code will update the heading as a user changes the value in the text field. 
Angular has event listeners on the ng-model directive which watch for changes. As soon as a 
change is detected, then it fires off a function which alerts the other instances bound to the 
model that the value has changed and to update their values
Directives 
Extending HTML
Native Directives 
Angular ships with native directives for structure. These directives are restricted as HTML attributes: 
● ng-app: Declares your app on the view and binds it to an angular module. You can only have 
one ng-app directive per view. 
● ng-controller: Sections off pieces of the HTML and binds them to a controller. Unless nested, 
controllers each have their own scope so if you want to share data between controllers you have 
to use: 
o A factory or a service 
o Dependency injection to pass in a parameter or use a resolve 
o sessionStorage or localStorage 
o $rootScope 
● ng-model: Way of wiring input elements to your controller and/or items on your view for “two 
way binding.” Ng-model shares data from the view to the controller and vice versa. 
● ng-click: Runs whatever expression or function you set on an HTML tag. I.e., <button 
type=“button” ng-click=“submit(order)”>Submit</button>
Native Directives (cont) 
● ng-class: Set dynamic classes based on flags. 
<button ng-class=“{‘red’: clicked===true, ‘blue’: clicked!==true}” ng-click=“ 
clicked=!clicked”>Click Me!</button> 
● ng-style: Used to dynamically change style of an element. 
<p ng-style=“{‘color’: changeColor}”>Hello, World!</p> 
<button type=“button” ng-click=“changeColor=‘red’”>Change Color</button> 
● ng-repeat: Used to iterate through an array or an object. 
<ul> 
<li ng-repeat=“product in products”> 
{{product.name}} - {{product.price | currency: “USD$”}} 
</li> 
</ul>
Breaking down a directive 
.directive('myCustomer', function() { 
return { 
restrict: 'E', 
scope: { 
customerInfo: '=info' 
}, 
templateUrl: 'my-customer-plus-vojta.html' 
}; 
});
Breaking down a directive (cont.) 
Directives come with a number of options you can set. 
● Restrict: This option indicates how the directive will be declared in HTML. 
o E: Element. <my-customer></my-customer> 
o A: Attribute. <div my-customer></div> 
o C: Class name. <div class=”my-customer”></div> 
o M: Comment <!-- directive: my-customer --> 
● Transclude: If set to true, gives the template access to the parent scope and allows 
template to wrap content set from the parent scope. Good for wrapping arbitrary 
content. 
● Template/TemplateUrl: If your template is small, then you can write the HTML in 
the directive using template. Otherwise, use templateURL to link to an HTML file.
Breaking down a directive (cont.) 
● Scope: Determines whether the scope is a shared scope, a new scope, or an isolate 
scope. 
o If scope is set to true, then will create only one new scope for the directive 
regardless of how many instances appear on the page. 
o If you set an isolate scope using an object hash, then the directive won’t have 
access to the scope of the page’s controller, allowing one to manipulate data without 
compromising its integrity on the page. 
○ You can pass in data into or out of a directive that uses isolate scope by using local 
scope properties: 
■ “=”: Two way binding between local scope property and parent scope property 
of the same name. 
■ “@”: Reads the value passed in. 
■ “&”: Allows an external function or expression to be passed into the directive
Breaking down a directive (cont.) 
● Scope (cont): Example in action where $scope.naomi is equal to an object and the 
myCustomer directive prints out the customer object passed to it from an outside 
controller. 
<my-customer info="naomi"></my-customer> 
.directive('myCustomer', function() { 
return { 
restrict: 'E', 
scope: { 
customerInfo: '=info' 
}, 
templateUrl: 'my-customer-plus-vojta.html' 
}; 
});
Breaking down a directive (cont.) 
● Require: If another directive is required as a parent, then declare the name in the 
required option. 
● Controller: Used in nested directives; declares the controller the directive will use. 
● Link: Function that allows directive to manipulate the DOM. Example: 
link: function(scope, element, attrs){ 
element.bind(‘click’, function(){ 
element.html(‘Clicked!’); 
}) 
}
Services 
Exposing data and functions across ctrls
Factories and Services 
● Factories and services are blocks of code in JS files that allow you to share data or 
functions between controllers - in other words, between scopes 
● Services shipped with Angular include: $scope, $http, $window, and $route 
● Preferred to $rootScope because of modular nature 
● Factories are functions that return an object - and this object will contain data 
needed for the controller to access. For an example of how this might look: 
.factory(“MyFactory”, function(){ 
var testVar = “Hello, World!” 
return { 
myToken: function(){ 
return testVar; 
} //end inner function 
} //end 1st return 
}]) //end factory 
.controller(“MainCtrl”, function($scope, 
MyFactory){ 
$scope.myVar = MyFactory.myToken(); 
}) //in the view {{myVar}} displays “Hello, World!”
Factory w/ API Call 
app.factory('myBusinessData', ['$http', '$stateParams', '$state', '$window', 
function($http, $stateParams, $state, $window){ 
var sharedDataObject = { 
getBusiness: function(){ 
var promise = $http({method: 'GET', url: $window.sessionStorage.getItem("appPath") 
+ "business"}) 
.success(function(data, status, headers, config){ 
return data; 
}); 
return promise; 
} 
} 
return sharedDataObject; 
}])
Dependency Injection 
● A core aspect of services and factories is dependency 
injection. Inject the services you want available in a 
controller to access them. 
.controller(‘MainCtrl’, [‘$scope’, 
function($scope){ }]) 
o The square brackets are for minification so it remembers the 
service’s name
Angular UI 
Filling in the blanks
What is Angular UI? 
Angular UI is the companion suite to AngularJS. Written by the 
online AngularJS community, the files fill gaps in AngularJS and 
provide even more flexibility. Angular UI includes: 
● UI Router: for use instead of Angular’s native router to allow for 
nested states 
● UI Utils: Described as the Swiss Army Knife of Angular UI, UI 
Utilities include things such as event binders, jQuery 
passthrough, keypress, route checking, and infinite scroll 
● UI Bootstrap: Taking Twitter Bootstrap’s jQuery driven 
components and replacing them with Angular versions.
Routing with UI Router 
● Uses concept of states instead of routes 
o Uses $stateProvider service 
o To use, must inject ui.router when declaring your angular module. (I.e., 
angular.module(‘myApp’, [‘ui.router’]) 
● Allows for nested states, so you can have multiple paths and nested views from a parent 
state 
o ex: /clients/{{clientId}}/overview is a nested state of /clients/{{clientId}} 
o Can have more than one nested state - you can go as shallow or deep as you like 
● View is loaded into a container with the ui-view directive: <div ui-view></div> 
o If you’re using nested views, their templates must be passed in through the views 
option in the routing config; whatever name you choose in the config must be 
passed into the directive like so: <div ui-view=“content”></div> 
● Links use ui-sref directive <a href ui-sref=“home”>Home</a> 
● Can also link using Angular URL <a href=“#/home”>Home</a> 
● To access states in controllers, inject the $state service
Example of Config w/ UI Router 
$stateProvider 
.state('home', { 
url: "/home", 
templateUrl: "home.html", 
controller: "HomeCtrl" 
}) 
.state('home.calendar', { 
url: "/calendar", 
views: { 
"content": {templateUrl: "calendar_tab.html"} 
} 
})
UI Bootstrap 
Set of templates (HTML & JS directives) that make up common UI 
elements, such as: 
● Accordions 
● Carousel 
● Datepicker 
● Dropdown 
● Modal Windows 
● Pagination 
● Pop-overs 
● Progress Bar 
● Tooltips
UI Bootstrap (cont) 
Let’s take a look at what UI Bootstrap has to 
offer: http://angular-ui.github.io/bootstrap 
Play with the demos and get a real feel of how 
Angular can transform your front end.
Final Words
Sites that use Angular 
1. Video Upload: http://www.vevo.com/ 
2. Email Reminders: http://reme.io/ 
3. Conference Calls: https://confr.com/#!/ 
4. Social Recommendations for Travel: http://posse.com/ 
5. News: http://www.msnbc.com/ 
6. Game: http://clickortre.at/#/ 
7. Plan Travel Itinerary: http://mywanderlust.co/ 
You can check out more sites at https://builtwith.angularjs.org/
Further Resources 
● W3Schools Angular tutorial: http://www.w3schools.com/angular/ 
● Angular video tutorials: https://egghead.io/ 
● Angular’s official site with tutorials and documentation: 
https://angularjs.org/ 
● AngularJS Learning GitHub: 
https://github.com/jmcunningham/AngularJS-Learning 
● Scotch.io: http://scotch.io/ 
● ng-newsletter: http://www.ng-newsletter.com/ 
● Dan Wahlin’s Blog: 
http://weblogs.asp.net/dwahlin/Tags/AngularJS
Q&A 
Questions about AngularJS or 
Angular UI? Fire away!
Keep in touch! 
www.sarah-hudson.com 
sarah@sarah-hudson.com 
@SarahHudson2008

Weitere ähnliche Inhalte

Was ist angesagt?

AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introductionTania Gonzales
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JSBipin
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JSAkshay Mathur
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architectureMichael He
 
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarIntroduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarAppfinz Technologies
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesMohamad Al Asmar
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular jsMindfire Solutions
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJSInfragistics
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS introdizabl
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)Gary Arora
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseEPAM Systems
 

Was ist angesagt? (20)

5 angularjs features
5 angularjs features5 angularjs features
5 angularjs features
 
Angular js 1.3 basic tutorial
Angular js 1.3 basic tutorialAngular js 1.3 basic tutorial
Angular js 1.3 basic tutorial
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
 
Getting Started with Angular JS
Getting Started with Angular JSGetting Started with Angular JS
Getting Started with Angular JS
 
AngularJS
AngularJSAngularJS
AngularJS
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumarIntroduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumar
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key Features
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular js
 
AngularJS
AngularJSAngularJS
AngularJS
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS intro
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
 
Angular from Scratch
Angular from ScratchAngular from Scratch
Angular from Scratch
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 

Ähnlich wie Angular js 1.3 presentation for fed nov 2014

Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSShyjal Raazi
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to AngularjsGaurav Agrawal
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basicsRavindra K
 
Angular js interview question answer for fresher
Angular js interview question answer for fresherAngular js interview question answer for fresher
Angular js interview question answer for fresherRavi Bhadauria
 
Introduction to AngularJS By Bharat Makwana
Introduction to AngularJS By Bharat MakwanaIntroduction to AngularJS By Bharat Makwana
Introduction to AngularJS By Bharat MakwanaBharat Makwana
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionOleksii Prohonnyi
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development GuideNitin Giri
 
One Weekend With AngularJS
One Weekend With AngularJSOne Weekend With AngularJS
One Weekend With AngularJSYashobanta Bai
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSAnass90
 
Angular js
Angular jsAngular js
Angular jsymtech
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIEric Wise
 
Angular Project Report
 Angular Project Report Angular Project Report
Angular Project ReportKodexhub
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS BasicsRavi Mone
 

Ähnlich wie Angular js 1.3 presentation for fed nov 2014 (20)

Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
 
Angular js interview question answer for fresher
Angular js interview question answer for fresherAngular js interview question answer for fresher
Angular js interview question answer for fresher
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
 
Introduction to AngularJS By Bharat Makwana
Introduction to AngularJS By Bharat MakwanaIntroduction to AngularJS By Bharat Makwana
Introduction to AngularJS By Bharat Makwana
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: Introduction
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
One Weekend With AngularJS
One Weekend With AngularJSOne Weekend With AngularJS
One Weekend With AngularJS
 
Itroducing Angular JS
Itroducing Angular JSItroducing Angular JS
Itroducing Angular JS
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Angular Basics.pptx
Angular Basics.pptxAngular Basics.pptx
Angular Basics.pptx
 
AngularJS
AngularJSAngularJS
AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPI
 
Angular Project Report
 Angular Project Report Angular Project Report
Angular Project Report
 
Angularjs basic part01
Angularjs basic part01Angularjs basic part01
Angularjs basic part01
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 

Kürzlich hochgeladen

SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 

Kürzlich hochgeladen (20)

SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 

Angular js 1.3 presentation for fed nov 2014

  • 1. Intro to AngularJS Overview on AngularJS 1.3 & Angular UI
  • 3. What is AngularJS? ● AngularJS is an MVC framework for web apps, allowing devs to use only HTML, CSS, and JavaScript on the front-end. ● It is maintained and supported by Google ● Searches for AngularJS have shot up over the past year, indicating that it's the next big thing in the JS and front-end world ● Alternatives: Knockout, Ember, Backbone
  • 4. Why Angular? ● Create custom HTML elements through directives, allowing further manipulation of the DOM o ex: Tags <dropdown></dropdown> can be used for a custom dropdown, pulling from a template.html file for a reusable dropdown ● Layered on top of jQlite instead of jQuery - lighter weight code and less lines of code for faster, more efficient load ● Flexible - Angular puts you in control of HTML elements and how it interfaces with JS and the back end ● HTML5 Hybrid Mobile Apps can be built using AngularJS ● Modular, meaning that it’s more geared towards modules of code that you can save in one file and reuse again and again throughout your app
  • 5. Basic Components of Angular ● Expressions - One of the most basic components of Angular. Expressions allow you to evaluate calculations or variables and print data on the view. They are typically surrounded by double curly braces {{5 + 5}}, though you can also use ng-bind ● Directives - Allow you to extend native HTML elements and write your own HTML tags and attributes. With directives, you can create a descriptive tag for easier, faster readability and store a regularly used piece of code in one file. ● Controllers - JavaScript functions that allow you to access and manipulate data. You can have one controller per page or multiple controllers for separate sections of the page. ● Views - The templates used for your web pages. ● Scope - Context where data & values are stored so that all components have access to it. This is how you can display data on your views and send data from user input on your view. ● Filters - JavaScript functions that format data. Angular ships with several built-in filters, such as date, limitTo, orderBy, and currency
  • 6. Basic Components of Angular (cont.) ● Factories and Services - JavaScript code that is independent of controllers and views. Typically, these are functions that return data to share among different sections of your app. ● Modules - The components of your Angular app, such as directives, controllers, and services. However, modules can also be thought of as different sections of your app separated out for improved readability and organization. ● Dependency Injection - The way that an Angular controller is made aware of a service or factory that will be used.
  • 7. Native Routing w/ AngularJS ● Uses the $locationProvider service for the configuration module ● To use, must inject ngRoute service into your angular module (i.e., angular.module(‘myApp’, [‘ngRoute’]) ● Routes are one level deep, meaning that you can have /client={{clientId}} but not /client/{{clientId}} ● View is loaded into the ng-view directive: <ng-view></ng-view> ● Links are determined by what mode you’re running your app in: o Hashbang mode is the default for Angular. This appends a hash symbol to your routes: <a href=“#/home”>Home</a> or <a href=“#!/home”>Home</a>. Using a suffix (such as the ! symbol) is good for SEO. o HTML5 mode prettifies your URIs: <a href=“/home”>Home</a> o For SEO purposes, you may need to run a headless WebKit scriptable such as PhantomJS ● To access your $route options and parameters in your controllers, you can pass in these services: $route, $routeParams, and $location
  • 8. Example of Native Routing w/ AngularJS angular.module('MyApp', ['ngRoute', 'ngResource']) .config(function($routeProvider, $locationProvider) { $routeProvider .when('/', { templateUrl:'home.html', controller: 'HomeCtrl' }) .when('/user-id=:id, { templateUrl: user_profile.html', controller: 'UserProfileCtrl' }) })
  • 9. Generating Angular Files Simple: Include a link to the Angular library in the head of your HTML and set up the JS file and declare ng-app yourself. Advanced: Use an NPM package to scaffold a local development environment along with the basic files necessary for an Angular app. I use Yeoman.io, which packages Yo, Bower, and Grunt. Yo - Automagically generates common files (like Bootstrap CSS files and JS libraries like Angular) Bower - Dependency Management (This means you can pull files and packages from github, like Angular UI, and automatically declare them as dependent packages in your angular app so angular “sees” them) Grunt - Server, Testing, and Automated Task Running (unit tests, minification, compilation)
  • 10. Scope Accessing from the controller and view
  • 11. A Word on Scope ● Scope is used to determine where a variable will be accessible in your app. ● In Angular, each controller creates its own scope, meaning a scope variable is only good in that controller or child controllers ● Some views can have multiple controllers or multiple scopes - you can access a variable across scopes using $rootScope o Note: The “Angular way” to share a variable or piece of data across controllers is actually to use factories and services
  • 12. A Word on Scope (cont) ● When you declare a variable in your controller, you can use a local variable only viewable by the controller (var testVar) or a $scope variable, which the front end can display ($scope.testVar) ● To display $scope variables, use double curly braces in your HTML ({{}}) or use ng-bind (<span ng-bind=” testVar”></span> ● Some devs prefer ng-bind because of a “blink and flash” - this can also be solved by preventing the page from loading before the data comes in
  • 13. Two Way Binding Angular does something cool with $scope variables - two way binding.This means that every instance of a variable is updated as the value is manipulated - in other words, updating one triggers a refresh of the DOM. Example: <h1>Hello, {{contact.name}}!</h1> <input type=“text” ng-model=“contact.name” /> The above code will update the heading as a user changes the value in the text field. Angular has event listeners on the ng-model directive which watch for changes. As soon as a change is detected, then it fires off a function which alerts the other instances bound to the model that the value has changed and to update their values
  • 15. Native Directives Angular ships with native directives for structure. These directives are restricted as HTML attributes: ● ng-app: Declares your app on the view and binds it to an angular module. You can only have one ng-app directive per view. ● ng-controller: Sections off pieces of the HTML and binds them to a controller. Unless nested, controllers each have their own scope so if you want to share data between controllers you have to use: o A factory or a service o Dependency injection to pass in a parameter or use a resolve o sessionStorage or localStorage o $rootScope ● ng-model: Way of wiring input elements to your controller and/or items on your view for “two way binding.” Ng-model shares data from the view to the controller and vice versa. ● ng-click: Runs whatever expression or function you set on an HTML tag. I.e., <button type=“button” ng-click=“submit(order)”>Submit</button>
  • 16. Native Directives (cont) ● ng-class: Set dynamic classes based on flags. <button ng-class=“{‘red’: clicked===true, ‘blue’: clicked!==true}” ng-click=“ clicked=!clicked”>Click Me!</button> ● ng-style: Used to dynamically change style of an element. <p ng-style=“{‘color’: changeColor}”>Hello, World!</p> <button type=“button” ng-click=“changeColor=‘red’”>Change Color</button> ● ng-repeat: Used to iterate through an array or an object. <ul> <li ng-repeat=“product in products”> {{product.name}} - {{product.price | currency: “USD$”}} </li> </ul>
  • 17. Breaking down a directive .directive('myCustomer', function() { return { restrict: 'E', scope: { customerInfo: '=info' }, templateUrl: 'my-customer-plus-vojta.html' }; });
  • 18. Breaking down a directive (cont.) Directives come with a number of options you can set. ● Restrict: This option indicates how the directive will be declared in HTML. o E: Element. <my-customer></my-customer> o A: Attribute. <div my-customer></div> o C: Class name. <div class=”my-customer”></div> o M: Comment <!-- directive: my-customer --> ● Transclude: If set to true, gives the template access to the parent scope and allows template to wrap content set from the parent scope. Good for wrapping arbitrary content. ● Template/TemplateUrl: If your template is small, then you can write the HTML in the directive using template. Otherwise, use templateURL to link to an HTML file.
  • 19. Breaking down a directive (cont.) ● Scope: Determines whether the scope is a shared scope, a new scope, or an isolate scope. o If scope is set to true, then will create only one new scope for the directive regardless of how many instances appear on the page. o If you set an isolate scope using an object hash, then the directive won’t have access to the scope of the page’s controller, allowing one to manipulate data without compromising its integrity on the page. ○ You can pass in data into or out of a directive that uses isolate scope by using local scope properties: ■ “=”: Two way binding between local scope property and parent scope property of the same name. ■ “@”: Reads the value passed in. ■ “&”: Allows an external function or expression to be passed into the directive
  • 20. Breaking down a directive (cont.) ● Scope (cont): Example in action where $scope.naomi is equal to an object and the myCustomer directive prints out the customer object passed to it from an outside controller. <my-customer info="naomi"></my-customer> .directive('myCustomer', function() { return { restrict: 'E', scope: { customerInfo: '=info' }, templateUrl: 'my-customer-plus-vojta.html' }; });
  • 21. Breaking down a directive (cont.) ● Require: If another directive is required as a parent, then declare the name in the required option. ● Controller: Used in nested directives; declares the controller the directive will use. ● Link: Function that allows directive to manipulate the DOM. Example: link: function(scope, element, attrs){ element.bind(‘click’, function(){ element.html(‘Clicked!’); }) }
  • 22. Services Exposing data and functions across ctrls
  • 23. Factories and Services ● Factories and services are blocks of code in JS files that allow you to share data or functions between controllers - in other words, between scopes ● Services shipped with Angular include: $scope, $http, $window, and $route ● Preferred to $rootScope because of modular nature ● Factories are functions that return an object - and this object will contain data needed for the controller to access. For an example of how this might look: .factory(“MyFactory”, function(){ var testVar = “Hello, World!” return { myToken: function(){ return testVar; } //end inner function } //end 1st return }]) //end factory .controller(“MainCtrl”, function($scope, MyFactory){ $scope.myVar = MyFactory.myToken(); }) //in the view {{myVar}} displays “Hello, World!”
  • 24. Factory w/ API Call app.factory('myBusinessData', ['$http', '$stateParams', '$state', '$window', function($http, $stateParams, $state, $window){ var sharedDataObject = { getBusiness: function(){ var promise = $http({method: 'GET', url: $window.sessionStorage.getItem("appPath") + "business"}) .success(function(data, status, headers, config){ return data; }); return promise; } } return sharedDataObject; }])
  • 25. Dependency Injection ● A core aspect of services and factories is dependency injection. Inject the services you want available in a controller to access them. .controller(‘MainCtrl’, [‘$scope’, function($scope){ }]) o The square brackets are for minification so it remembers the service’s name
  • 26. Angular UI Filling in the blanks
  • 27. What is Angular UI? Angular UI is the companion suite to AngularJS. Written by the online AngularJS community, the files fill gaps in AngularJS and provide even more flexibility. Angular UI includes: ● UI Router: for use instead of Angular’s native router to allow for nested states ● UI Utils: Described as the Swiss Army Knife of Angular UI, UI Utilities include things such as event binders, jQuery passthrough, keypress, route checking, and infinite scroll ● UI Bootstrap: Taking Twitter Bootstrap’s jQuery driven components and replacing them with Angular versions.
  • 28. Routing with UI Router ● Uses concept of states instead of routes o Uses $stateProvider service o To use, must inject ui.router when declaring your angular module. (I.e., angular.module(‘myApp’, [‘ui.router’]) ● Allows for nested states, so you can have multiple paths and nested views from a parent state o ex: /clients/{{clientId}}/overview is a nested state of /clients/{{clientId}} o Can have more than one nested state - you can go as shallow or deep as you like ● View is loaded into a container with the ui-view directive: <div ui-view></div> o If you’re using nested views, their templates must be passed in through the views option in the routing config; whatever name you choose in the config must be passed into the directive like so: <div ui-view=“content”></div> ● Links use ui-sref directive <a href ui-sref=“home”>Home</a> ● Can also link using Angular URL <a href=“#/home”>Home</a> ● To access states in controllers, inject the $state service
  • 29. Example of Config w/ UI Router $stateProvider .state('home', { url: "/home", templateUrl: "home.html", controller: "HomeCtrl" }) .state('home.calendar', { url: "/calendar", views: { "content": {templateUrl: "calendar_tab.html"} } })
  • 30. UI Bootstrap Set of templates (HTML & JS directives) that make up common UI elements, such as: ● Accordions ● Carousel ● Datepicker ● Dropdown ● Modal Windows ● Pagination ● Pop-overs ● Progress Bar ● Tooltips
  • 31. UI Bootstrap (cont) Let’s take a look at what UI Bootstrap has to offer: http://angular-ui.github.io/bootstrap Play with the demos and get a real feel of how Angular can transform your front end.
  • 33. Sites that use Angular 1. Video Upload: http://www.vevo.com/ 2. Email Reminders: http://reme.io/ 3. Conference Calls: https://confr.com/#!/ 4. Social Recommendations for Travel: http://posse.com/ 5. News: http://www.msnbc.com/ 6. Game: http://clickortre.at/#/ 7. Plan Travel Itinerary: http://mywanderlust.co/ You can check out more sites at https://builtwith.angularjs.org/
  • 34. Further Resources ● W3Schools Angular tutorial: http://www.w3schools.com/angular/ ● Angular video tutorials: https://egghead.io/ ● Angular’s official site with tutorials and documentation: https://angularjs.org/ ● AngularJS Learning GitHub: https://github.com/jmcunningham/AngularJS-Learning ● Scotch.io: http://scotch.io/ ● ng-newsletter: http://www.ng-newsletter.com/ ● Dan Wahlin’s Blog: http://weblogs.asp.net/dwahlin/Tags/AngularJS
  • 35. Q&A Questions about AngularJS or Angular UI? Fire away!
  • 36. Keep in touch! www.sarah-hudson.com sarah@sarah-hudson.com @SarahHudson2008