SlideShare ist ein Scribd-Unternehmen logo
1 von 17
AngularJS
Pasi Manninen
JAMK University of Applied Sciences
Slide version Mar 6th, 2014
AngularJS
• Google's open-source framework for developing Web
applications
• Target is creating single-page web applications with
MVC capability
• 100% JavaScript and 100% client side
• Updates very often (about 4 times a month, 1st version
June 2012)
• Supports modern desktop and mobile browsers
• Very good documentation and tutorials
– http://angularjs.org
– http://www.youtube.com/user/angularjs
AngularJS, Pasi Manninen. 2
Remember read: http://docs.angularjs.org/guide/introduction
Angular Consepts
AngularJS, Pasi Manninen. 3
http://docs.angularjs.org/guide/concepts
Angular Directives (notable)
AngularJS, Pasi Manninen. 4
http://en.wikipedia.org/wiki/AngularJS
Key Features
• Data Binding
– two-way data-binding automatically handles values between
model and view
– http://jsfiddle.net/HweGq/
• Scope
– object that refers to the model
– glues the controller and the view
• Controllers
– JavaScript functions which are bound to a particular scope
– http://jsfiddle.net/HweGq/1/ (scope variable problem)
– http://jsfiddle.net/HweGq/2/ (corrected with controller)
– http://jsfiddle.net/HweGq/3/ (controller inside module)
– http://jsfiddle.net/HweGq/4/ (controller with methods)
AngularJS, Pasi Manninen. 5
Key Features
• Services
– angular comes with several built-in services (for
example $http to make a XMLHttpRequests)
– singleton objects which are instantiated only once
in app
– can be made own services with factory
– http://jsfiddle.net/HweGq/5/ (share data between
controllers)
AngularJS, Pasi Manninen. 6
Example: Services
• Use service to load JSON from the server
• http://ptm.fi/angular/MovieExample/
AngularJS, Pasi Manninen. 7
<html lang="en" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>AngularJS - movie service</title>
<script src="angular.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<div ng-controller="MovieController">
<h2>{{movieName}}</h2>
<video controls ng-src="{{movieUrl}}"></video>
</div>
</body>
</html>
// app.js
var myApp = angular.module('myApp', []);
myApp.factory('MovieService', function ($http) {
var data = {};
data.url = "http://ptm.fi/angular/MovieExample/movie.php";
data.getMovie = function() {
return $http.get(data.url);
}
return data;
});
myApp.controller('MovieController', function($scope,$sce,MovieService) {
MovieService.getMovie().success(function (response) {
$scope.movieName = response.name;
var movieUrl = response.url;
$scope.movieUrl = $sce.trustAsResourceUrl(movieUrl);
});
});
<?php // movie.php
echo '{"url":"http://fin.clip-1.filmtrailer.com/11195_41463_a_6.mp4","name":"21 tapaa pilata avioliitto"}';
?>
Key Features
• Filters
– selects a subset of items from array and returns a new array
– http://jsfiddle.net/xLrZF/
• Directives
– directives are markers on a DOM element (like elements, attributes,
css, …)
– angular has own build-in directives (ngBind, ngModel, …)
– can be made own ones
– http://jsfiddle.net/WAN4H/ (as element)
– http://jsfiddle.net/WAN4H/1/ (as attribute)
– http://jsfiddle.net/WAN4H/2/ (as class attribute)
– http://jsfiddle.net/WAN4H/3/ (as comment)
– http://jsfiddle.net/WAN4H/4/ (with events)
– http://jsfiddle.net/WAN4H/5/ (with events to controller)
– try nice demos at http://docs.angularjs.org/guide/directive
AngularJS, Pasi Manninen. 8
’E’ – Element
’A’ – Attribute (default)
’C’ – Class
’M’ – Comment
Key Features
• Templates
– rendered view with information from the controller
and model
– can be one file (like index.html) or multiple views in
one page using “partials”
– partials are included to main page using $route
service with ngView directive
– http://ptm.fi/angular/TemplatesExample/ (no
templates used)
– http://ptm.fi/angular/TemplatesExample/index2.html
(templateUrl used in app2.js)
AngularJS, Pasi Manninen. 9
Key Features
• Routing (switch views)
– use ng-view directive that angular uses as a
container (to switch between views)
– links to controller and template with config
function and $routeProvider
– http://ptm.fi/angular/RoutingExample/
(one template)
AngularJS, Pasi Manninen. 10
Example: Routing (1/2)
• Use ng-view directive to show to different routing templates
• http://ptm.fi/angular/RoutingExample2/
• index.html and templates: app.html, user.html
AngularJS, Pasi Manninen. 11
<html lang="en" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>AngularJS - routing example</title>
<script src="angular.min.js"></script>
<script src="angular-route.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<ng-view></ng-view>
</body>
</html> <div ng-controller="AppCtrl">
<table>
<tr><th>Firstname</th><th>Lastname</th></tr>
<tr ng-repeat="user in users" ng-click="clicked($index)">
<td>{{user.firstname}}</td>
<td>{{user.lastname}}</td>
</tr>
</table>
</div>
<div ng-controller="UserCtrl">
<h3>User Details</h3>
<p>
{{user.firstname}} {{user.lastname}}<br/>
<img ng-src="{{user.image}}"/><br/>
{{user.details}}
</p>
</div>
click name to change
template in ng-view
Example: Routing (2/2)
• Use ng-view directive to show to different routing templates
• http://ptm.fi/angular/RoutingExample2/
• app.js (routes, controllers and one service)
AngularJS, Pasi Manninen. 12
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(function($routeProvider){
$routeProvider
.when("/", { templateUrl: 'app.html', controller: 'AppCtrl‘ })
.when('/users/:userId', { templateUrl: 'user.html', controller: 'UserCtrl‘ })
.otherwise({redirectTo: '/'});
});
myApp.controller("UserCtrl", function($scope,$routeParams,UsersService) {
$scope.user = UsersService.users[$routeParams.userId];
});
myApp.controller("AppCtrl", function($scope,$location,UsersService){
$scope.users = UsersService.users;
$scope.clicked = function(index) {
$location.path("/users/"+index);
}
});
myApp.factory('UsersService', function () {
var users =
[
{firstname:"Kirsi",lastname:"Kernel",details:"Kirsi is..",image:"employee01.png"},
{firstname:"Matti",lastname:"Husso",details:"Matti is..",image:"employee02.png"}
];
return {users:users};
});
click name to change
template in ng-view
Hands-On: Users Demo - client
• Show all users, edit or delete from database
• Controllers:
– UsersCtrl
– AddUserCtrl
– EditUserCtrl
• Services:
– UsersService
• Routes
– /
– /addUser
– /edit/:userId
• Views
– users.html
– adduser.html
– edituser.html
• http://ptm.fi/angular/UsersDemo/
AngularJS, Pasi Manninen. 13
Hands-On: User Demo - database
• Use MySQL Workbench and create table
– table name is Users
– id primary key not null auto increment
– username, firstname and lastname as varchar
AngularJS, Pasi Manninen. 14
Hands-On: User Demo - server
• Use PHP
– config.php
– adduser.php
– deleteuser.php
– edituser.php
– getusers.php
AngularJS, Pasi Manninen. 15
INSERT INTO Users (username,firstname,lastname) VALUES….
DELETE FROM Users WHERE…..
UPDATE Users SET username=…..
SELECT * FROM Users…..
Exercise: Android devices
• Work through the tutorial to see how Angular
makes browsers smarter without the use of
extensions or plug-ins
• The tutorial guides you
through the entire process
of building a simple
application
• http://docs.angularjs.org/tutorial
AngularJS, Pasi Manninen. 16
Exercise: Finnkino
• Create an AngularJS based single page web
application which loads and shows the movie
data from the Finnkino web service
• A few keywords:
– bootstrap css
– own templates
– controls and services
– PHP to cache data
AngularJS, Pasi Manninen. 17
Tutorial is not included to this power point material.

Weitere ähnliche Inhalte

Was ist angesagt?

The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014Matt Raible
 
MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)Chris Clarke
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPressCaldera Labs
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverSpike Brehm
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSSimon Guest
 
Building an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationBuilding an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationDan Wahlin
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick Lee
 
Dart and AngularDart
Dart and AngularDartDart and AngularDart
Dart and AngularDartLoc Nguyen
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalCampDN
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSDen Odell
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introductionLuigi De Russis
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish MinutesDan Wahlin
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationEyal Vardi
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIVisual Engineering
 
Introducing AngularJS
Introducing AngularJSIntroducing AngularJS
Introducing AngularJSLoc Nguyen
 

Was ist angesagt? (20)

The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014
 
MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPress
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
 
Requirejs
RequirejsRequirejs
Requirejs
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
 
Workshop 21: React Router
Workshop 21: React RouterWorkshop 21: React Router
Workshop 21: React Router
 
Building an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationBuilding an End-to-End AngularJS Application
Building an End-to-End AngularJS Application
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
Dart and AngularDart
Dart and AngularDartDart and AngularDart
Dart and AngularDart
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
Managing JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJSManaging JavaScript Dependencies With RequireJS
Managing JavaScript Dependencies With RequireJS
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
Introducing AngularJS
Introducing AngularJSIntroducing AngularJS
Introducing AngularJS
 

Andere mochten auch

Wordpress Intro
Wordpress IntroWordpress Intro
Wordpress IntroRicha Goel
 
Responsive web design
Responsive web designResponsive web design
Responsive web designRicha Goel
 
Adobe AIR Programming to Desktop and Mobile
Adobe AIR Programming to Desktop and MobileAdobe AIR Programming to Desktop and Mobile
Adobe AIR Programming to Desktop and MobilePasi Manninen
 
UX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesUX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesNed Potter
 

Andere mochten auch (6)

PHP 2
PHP 2PHP 2
PHP 2
 
Php
PhpPhp
Php
 
Wordpress Intro
Wordpress IntroWordpress Intro
Wordpress Intro
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 
Adobe AIR Programming to Desktop and Mobile
Adobe AIR Programming to Desktop and MobileAdobe AIR Programming to Desktop and Mobile
Adobe AIR Programming to Desktop and Mobile
 
UX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesUX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and Archives
 

Ähnlich wie AngularJS

Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular jsTamer Solieman
 
A Story about AngularJS modularization development
A Story about AngularJS modularization developmentA Story about AngularJS modularization development
A Story about AngularJS modularization developmentJohannes Weber
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosLearnimtactics
 
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
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseEPAM Systems
 
MongoDB Days Silicon Valley: Building Applications with the MEAN Stack
MongoDB Days Silicon Valley: Building Applications with the MEAN StackMongoDB Days Silicon Valley: Building Applications with the MEAN Stack
MongoDB Days Silicon Valley: Building Applications with the MEAN StackMongoDB
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and conceptsSuresh Patidar
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSmurtazahaveliwala
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to AngularjsGaurav Agrawal
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersOswald Campesato
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architectureJasper Moelker
 
Single Page Applications Workshop Part II: Single Page Applications using Ang...
Single Page Applications Workshop Part II: Single Page Applications using Ang...Single Page Applications Workshop Part II: Single Page Applications using Ang...
Single Page Applications Workshop Part II: Single Page Applications using Ang...Jalal Mostafa
 

Ähnlich wie AngularJS (20)

Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
A Story about AngularJS modularization development
A Story about AngularJS modularization developmentA Story about AngularJS modularization development
A Story about AngularJS modularization development
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle StudiosAngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
 
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
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
MongoDB Days Silicon Valley: Building Applications with the MEAN Stack
MongoDB Days Silicon Valley: Building Applications with the MEAN StackMongoDB Days Silicon Valley: Building Applications with the MEAN Stack
MongoDB Days Silicon Valley: Building Applications with the MEAN Stack
 
Angular js workshop
Angular js workshopAngular js workshop
Angular js workshop
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
 
Custom directive and scopes
Custom directive and scopesCustom directive and scopes
Custom directive and scopes
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS
AngularJSAngularJS
AngularJS
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for Beginners
 
Angular - Beginner
Angular - BeginnerAngular - Beginner
Angular - Beginner
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
 
Single Page Applications Workshop Part II: Single Page Applications using Ang...
Single Page Applications Workshop Part II: Single Page Applications using Ang...Single Page Applications Workshop Part II: Single Page Applications using Ang...
Single Page Applications Workshop Part II: Single Page Applications using Ang...
 

Kürzlich hochgeladen

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Kürzlich hochgeladen (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

AngularJS

  • 1. AngularJS Pasi Manninen JAMK University of Applied Sciences Slide version Mar 6th, 2014
  • 2. AngularJS • Google's open-source framework for developing Web applications • Target is creating single-page web applications with MVC capability • 100% JavaScript and 100% client side • Updates very often (about 4 times a month, 1st version June 2012) • Supports modern desktop and mobile browsers • Very good documentation and tutorials – http://angularjs.org – http://www.youtube.com/user/angularjs AngularJS, Pasi Manninen. 2 Remember read: http://docs.angularjs.org/guide/introduction
  • 3. Angular Consepts AngularJS, Pasi Manninen. 3 http://docs.angularjs.org/guide/concepts
  • 4. Angular Directives (notable) AngularJS, Pasi Manninen. 4 http://en.wikipedia.org/wiki/AngularJS
  • 5. Key Features • Data Binding – two-way data-binding automatically handles values between model and view – http://jsfiddle.net/HweGq/ • Scope – object that refers to the model – glues the controller and the view • Controllers – JavaScript functions which are bound to a particular scope – http://jsfiddle.net/HweGq/1/ (scope variable problem) – http://jsfiddle.net/HweGq/2/ (corrected with controller) – http://jsfiddle.net/HweGq/3/ (controller inside module) – http://jsfiddle.net/HweGq/4/ (controller with methods) AngularJS, Pasi Manninen. 5
  • 6. Key Features • Services – angular comes with several built-in services (for example $http to make a XMLHttpRequests) – singleton objects which are instantiated only once in app – can be made own services with factory – http://jsfiddle.net/HweGq/5/ (share data between controllers) AngularJS, Pasi Manninen. 6
  • 7. Example: Services • Use service to load JSON from the server • http://ptm.fi/angular/MovieExample/ AngularJS, Pasi Manninen. 7 <html lang="en" ng-app="myApp"> <head> <meta charset="UTF-8"> <title>AngularJS - movie service</title> <script src="angular.min.js"></script> <script src="app.js"></script> </head> <body> <div ng-controller="MovieController"> <h2>{{movieName}}</h2> <video controls ng-src="{{movieUrl}}"></video> </div> </body> </html> // app.js var myApp = angular.module('myApp', []); myApp.factory('MovieService', function ($http) { var data = {}; data.url = "http://ptm.fi/angular/MovieExample/movie.php"; data.getMovie = function() { return $http.get(data.url); } return data; }); myApp.controller('MovieController', function($scope,$sce,MovieService) { MovieService.getMovie().success(function (response) { $scope.movieName = response.name; var movieUrl = response.url; $scope.movieUrl = $sce.trustAsResourceUrl(movieUrl); }); }); <?php // movie.php echo '{"url":"http://fin.clip-1.filmtrailer.com/11195_41463_a_6.mp4","name":"21 tapaa pilata avioliitto"}'; ?>
  • 8. Key Features • Filters – selects a subset of items from array and returns a new array – http://jsfiddle.net/xLrZF/ • Directives – directives are markers on a DOM element (like elements, attributes, css, …) – angular has own build-in directives (ngBind, ngModel, …) – can be made own ones – http://jsfiddle.net/WAN4H/ (as element) – http://jsfiddle.net/WAN4H/1/ (as attribute) – http://jsfiddle.net/WAN4H/2/ (as class attribute) – http://jsfiddle.net/WAN4H/3/ (as comment) – http://jsfiddle.net/WAN4H/4/ (with events) – http://jsfiddle.net/WAN4H/5/ (with events to controller) – try nice demos at http://docs.angularjs.org/guide/directive AngularJS, Pasi Manninen. 8 ’E’ – Element ’A’ – Attribute (default) ’C’ – Class ’M’ – Comment
  • 9. Key Features • Templates – rendered view with information from the controller and model – can be one file (like index.html) or multiple views in one page using “partials” – partials are included to main page using $route service with ngView directive – http://ptm.fi/angular/TemplatesExample/ (no templates used) – http://ptm.fi/angular/TemplatesExample/index2.html (templateUrl used in app2.js) AngularJS, Pasi Manninen. 9
  • 10. Key Features • Routing (switch views) – use ng-view directive that angular uses as a container (to switch between views) – links to controller and template with config function and $routeProvider – http://ptm.fi/angular/RoutingExample/ (one template) AngularJS, Pasi Manninen. 10
  • 11. Example: Routing (1/2) • Use ng-view directive to show to different routing templates • http://ptm.fi/angular/RoutingExample2/ • index.html and templates: app.html, user.html AngularJS, Pasi Manninen. 11 <html lang="en" ng-app="myApp"> <head> <meta charset="UTF-8"> <title>AngularJS - routing example</title> <script src="angular.min.js"></script> <script src="angular-route.min.js"></script> <script src="app.js"></script> </head> <body> <ng-view></ng-view> </body> </html> <div ng-controller="AppCtrl"> <table> <tr><th>Firstname</th><th>Lastname</th></tr> <tr ng-repeat="user in users" ng-click="clicked($index)"> <td>{{user.firstname}}</td> <td>{{user.lastname}}</td> </tr> </table> </div> <div ng-controller="UserCtrl"> <h3>User Details</h3> <p> {{user.firstname}} {{user.lastname}}<br/> <img ng-src="{{user.image}}"/><br/> {{user.details}} </p> </div> click name to change template in ng-view
  • 12. Example: Routing (2/2) • Use ng-view directive to show to different routing templates • http://ptm.fi/angular/RoutingExample2/ • app.js (routes, controllers and one service) AngularJS, Pasi Manninen. 12 var myApp = angular.module('myApp', ['ngRoute']); myApp.config(function($routeProvider){ $routeProvider .when("/", { templateUrl: 'app.html', controller: 'AppCtrl‘ }) .when('/users/:userId', { templateUrl: 'user.html', controller: 'UserCtrl‘ }) .otherwise({redirectTo: '/'}); }); myApp.controller("UserCtrl", function($scope,$routeParams,UsersService) { $scope.user = UsersService.users[$routeParams.userId]; }); myApp.controller("AppCtrl", function($scope,$location,UsersService){ $scope.users = UsersService.users; $scope.clicked = function(index) { $location.path("/users/"+index); } }); myApp.factory('UsersService', function () { var users = [ {firstname:"Kirsi",lastname:"Kernel",details:"Kirsi is..",image:"employee01.png"}, {firstname:"Matti",lastname:"Husso",details:"Matti is..",image:"employee02.png"} ]; return {users:users}; }); click name to change template in ng-view
  • 13. Hands-On: Users Demo - client • Show all users, edit or delete from database • Controllers: – UsersCtrl – AddUserCtrl – EditUserCtrl • Services: – UsersService • Routes – / – /addUser – /edit/:userId • Views – users.html – adduser.html – edituser.html • http://ptm.fi/angular/UsersDemo/ AngularJS, Pasi Manninen. 13
  • 14. Hands-On: User Demo - database • Use MySQL Workbench and create table – table name is Users – id primary key not null auto increment – username, firstname and lastname as varchar AngularJS, Pasi Manninen. 14
  • 15. Hands-On: User Demo - server • Use PHP – config.php – adduser.php – deleteuser.php – edituser.php – getusers.php AngularJS, Pasi Manninen. 15 INSERT INTO Users (username,firstname,lastname) VALUES…. DELETE FROM Users WHERE….. UPDATE Users SET username=….. SELECT * FROM Users…..
  • 16. Exercise: Android devices • Work through the tutorial to see how Angular makes browsers smarter without the use of extensions or plug-ins • The tutorial guides you through the entire process of building a simple application • http://docs.angularjs.org/tutorial AngularJS, Pasi Manninen. 16
  • 17. Exercise: Finnkino • Create an AngularJS based single page web application which loads and shows the movie data from the Finnkino web service • A few keywords: – bootstrap css – own templates – controls and services – PHP to cache data AngularJS, Pasi Manninen. 17 Tutorial is not included to this power point material.