SlideShare a Scribd company logo
1 of 20
Les Fondamentaux d’Angular JS
Hmidi Hamdi
C’est quoi Angular JS?
- AngularJS est un Framework JavaScript open-source développé par Google.
- Ce Framework facilite grandement le développement d'application web selon le
modèle MVC* (Modèle Vue Controleur).
- Utilisée pour développer des applications SPA*(Single Page Application).
- Framework des applications coté client.
SPA ”Single Page Application”
MVC “Model View Controller”
Exemple
http://devfest.google-club.com/
Pourquoi Angular JS?
- Utilise le modèle MVW (Model View Wathever).
- Flexible avec les filtres.
- Ecrire moins du code.
Hello Angular JS !
<!doctype html>
<html ng-app>
<head>
<title>Hello Angular JS</title>
<SCRIPT TYPE="text/javascript" src="JS/angular.min.js"></SCRIPT>
</head>
<body >
<h1> {{« Hello Angular JS» }} </h1>
</body>
</html>
Directives, Filters and Data binding
Directives
Une directive est une stratégie pour enseigner des nouveaux astuces au HTML.
Càd rendre le HTML Dynamique.
Exemple
<!doctype html>
<html>
<head>
<title>Exemple 1</title>
<SCRIPT TYPE="text/javascript" src="JS/angular.min.js"></SCRIPT>
</head>
<body ng-app>
<input type="text" ng-model="name" >
<h1>Hello {{name}} </h1>
</body>
</html>
Directive
Directive
Data Binding
Views, Controllers and Scope
View Controller$Scope
Exemple : View and Controller
<!doctype html>
<html ng-app >
<head>
<title>Exemple 2</title>
<SCRIPT TYPE = "text/javascript" src= "JS/angular.min.js"></SCRIPT>
<script type="text/javascript" src="JS/Controller1.js"></script>
</head>
<body ng-controller="monContr" >
<h1> Membres </h1>
<div id = "membre" ng-repeat = "item in items" >
<h1>Nom et Prenom : </h1> {{item.nom}} - {{item.prenom}}
<h2>Club : </h2> {{ item.club }}
</div>
</body>
</html>
function monContr($scope){
$scope.items=[{‘’nom’’:"Hamdi",’’prenom’’:"Hmidi",’’club’’:"IGC"
},
{‘’nom’’:"Marwan",’’prenom’’:"Zouinkhi",’’club’’:"IGC"},
{‘’nom’’:"Bouchlema",’’prenom’’:"Sabri",’’club’’:"IGC"}];
}
Modules
Modules
C’est un conteneur d’application , Chaque application web peut être constituée par plusieurs modules chaque module possède ça fonctionnalité.
Var myapp= angular.module(‘module_name’,[]);
Myapp.controller(‘test’, function($scope){
//TODO code
});
<html ng-app=‘’ module_name’’>
Events
<!doctype html>
<html ng-app="myapp">
<head>
<title>EVENTS</title>
<SCRIPT TYPE="text/javascript" src="angular.min.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" src="cont.js"></SCRIPT>
</head>
<body ng-controller="test">
<form action="#">
<input type="text" ng-model="newval">
<button ng-click="add()">Add</button>
</form>
<ul>
<li ng-repeat="item in items">{{item}}</li>
</ul>
</body>
</html>
var myapp=angular.module('myapp',[]);
myapp.controller('test',function($scope){
$scope.items=['IGC','SP','MIC','OVET','UGET','UGTE'];
$scope.add= function(){
$scope.items.push($scope.newval);
$scope.newval='';
}
});
Angular et AJAX
$scope.todos=[];
$http.get('data.php').success(function(data){
$scope.todos=data;
});
[
{
"name":"Tache a faire ",
"done":"false"
},
{
"name":"Tache a faire ",
"done":"false"
}
]
Routes
<!DOCTYPE html>
<html ng-app="myapp">
<head>
<script src="angular.js"></script>
<script src="angular-route.js"></script>
<script src="app.js"></script>
</head>
<body>
<div ng-view></div>
</body>
</html>
var myapp = angular.module("myapp", ['ngRoute']);
myapp.config(
function($routeProvider) {
$routeProvider.
when('/page1', {
templateUrl: 'page1.html',
controller: 'page1Ctrl'
}).
when('/page2/:id', {
templateUrl: 'page2.html',
controller: 'page2Ctrl'
}).
otherwise({
redirectTo: '/page1'
});
}
);
myapp.controller("page1Ctrl", function($scope) {
$scope.page = "1";
});
myapp.controller("page2Ctrl", function($scope, $routeParams) {
$scope.page = $routeParams.id;
});
Factories
var myapp=angular.module("myapp",[]);
myapp.factory("DataFactory",function($http){
var Factory={};
var Response=$http.get("data.json");
Factory.DataGet= function(){
return Response;
}
return Factory;
});
myapp.controller('Ctrl', function($scope,DataFactory){
$scope.tab=[];
DataFactory.DataGet().success(function(dt){
$scope.tab=dt;
});
});
[
{
"name":"Hamdi",
"surname":"Hmidi"
},
{
"name":"Sabri",
"surname":"Bouchlema"
}
]
Let’s Code
Merci pour votre attention

More Related Content

Viewers also liked

Letter a new program pp
Letter a new program ppLetter a new program pp
Letter a new program ppdenegri77
 
Shivam | Summer Internship Report |
Shivam | Summer Internship Report |Shivam | Summer Internship Report |
Shivam | Summer Internship Report |shivam mishra
 
Alla scoperta di Marte
Alla scoperta di MarteAlla scoperta di Marte
Alla scoperta di Martechreact
 
promotional-campaign-wordpress-woocommerce-service
promotional-campaign-wordpress-woocommerce-servicepromotional-campaign-wordpress-woocommerce-service
promotional-campaign-wordpress-woocommerce-serviceDigital Systems
 
Volcanic dualism
Volcanic dualismVolcanic dualism
Volcanic dualismchreact
 
PIOGGIA DALLO SPAZIO
PIOGGIA DALLO SPAZIOPIOGGIA DALLO SPAZIO
PIOGGIA DALLO SPAZIOchreact
 
Формирование деловой программы мероприятия. Ульяна Бурылова
Формирование деловой программы мероприятия. Ульяна БурыловаФормирование деловой программы мероприятия. Ульяна Бурылова
Формирование деловой программы мероприятия. Ульяна Бурыловаlashkova
 
Антон Мосягин для I_Love_Events.conf
Антон Мосягин для I_Love_Events.confАнтон Мосягин для I_Love_Events.conf
Антон Мосягин для I_Love_Events.conflashkova
 
Distillazione dell’urina
Distillazione dell’urinaDistillazione dell’urina
Distillazione dell’urinachreact
 
To mars and beyond
To mars and beyond To mars and beyond
To mars and beyond chreact
 
Poster "De Caprariis"
Poster "De Caprariis"Poster "De Caprariis"
Poster "De Caprariis"chreact
 
Illuminazione artificiale
Illuminazione artificialeIlluminazione artificiale
Illuminazione artificialechreact
 
опыт проведения многодневных мероприятий
опыт проведения многодневных мероприятийопыт проведения многодневных мероприятий
опыт проведения многодневных мероприятийlashkova
 
Pericoli dallo spazio
Pericoli dallo spazioPericoli dallo spazio
Pericoli dallo spaziochreact
 
Pres segrè
Pres segrèPres segrè
Pres segrèchreact
 
An adventure on the red planet
An adventure on the red planetAn adventure on the red planet
An adventure on the red planetchreact
 
The powerofgreenlight
The powerofgreenlightThe powerofgreenlight
The powerofgreenlightchreact
 

Viewers also liked (19)

Cubiertas & Fachadas
Cubiertas & FachadasCubiertas & Fachadas
Cubiertas & Fachadas
 
Letter a new program pp
Letter a new program ppLetter a new program pp
Letter a new program pp
 
Shivam | Summer Internship Report |
Shivam | Summer Internship Report |Shivam | Summer Internship Report |
Shivam | Summer Internship Report |
 
Alla scoperta di Marte
Alla scoperta di MarteAlla scoperta di Marte
Alla scoperta di Marte
 
promotional-campaign-wordpress-woocommerce-service
promotional-campaign-wordpress-woocommerce-servicepromotional-campaign-wordpress-woocommerce-service
promotional-campaign-wordpress-woocommerce-service
 
Volcanic dualism
Volcanic dualismVolcanic dualism
Volcanic dualism
 
PIOGGIA DALLO SPAZIO
PIOGGIA DALLO SPAZIOPIOGGIA DALLO SPAZIO
PIOGGIA DALLO SPAZIO
 
Формирование деловой программы мероприятия. Ульяна Бурылова
Формирование деловой программы мероприятия. Ульяна БурыловаФормирование деловой программы мероприятия. Ульяна Бурылова
Формирование деловой программы мероприятия. Ульяна Бурылова
 
Антон Мосягин для I_Love_Events.conf
Антон Мосягин для I_Love_Events.confАнтон Мосягин для I_Love_Events.conf
Антон Мосягин для I_Love_Events.conf
 
Distillazione dell’urina
Distillazione dell’urinaDistillazione dell’urina
Distillazione dell’urina
 
To mars and beyond
To mars and beyond To mars and beyond
To mars and beyond
 
Poster "De Caprariis"
Poster "De Caprariis"Poster "De Caprariis"
Poster "De Caprariis"
 
Illuminazione artificiale
Illuminazione artificialeIlluminazione artificiale
Illuminazione artificiale
 
опыт проведения многодневных мероприятий
опыт проведения многодневных мероприятийопыт проведения многодневных мероприятий
опыт проведения многодневных мероприятий
 
Ng-init
Ng-init Ng-init
Ng-init
 
Pericoli dallo spazio
Pericoli dallo spazioPericoli dallo spazio
Pericoli dallo spazio
 
Pres segrè
Pres segrèPres segrè
Pres segrè
 
An adventure on the red planet
An adventure on the red planetAn adventure on the red planet
An adventure on the red planet
 
The powerofgreenlight
The powerofgreenlightThe powerofgreenlight
The powerofgreenlight
 

More from Hamdi Hmidi

Getting started with node JS
Getting started with node JSGetting started with node JS
Getting started with node JSHamdi Hmidi
 
Ng init | EPI Sousse
Ng init | EPI SousseNg init | EPI Sousse
Ng init | EPI SousseHamdi Hmidi
 
Pentaho | Data Integration & Report designer
Pentaho | Data Integration & Report designerPentaho | Data Integration & Report designer
Pentaho | Data Integration & Report designerHamdi Hmidi
 
Javascript - Getting started | DevCom ISITCom
Javascript - Getting started | DevCom ISITComJavascript - Getting started | DevCom ISITCom
Javascript - Getting started | DevCom ISITComHamdi Hmidi
 
Modern web application devlopment workflow
Modern web application devlopment workflowModern web application devlopment workflow
Modern web application devlopment workflowHamdi Hmidi
 
Les Basiques - Web Développement HTML5, CSS3, JS et PHP
Les Basiques - Web  Développement HTML5, CSS3, JS et PHPLes Basiques - Web  Développement HTML5, CSS3, JS et PHP
Les Basiques - Web Développement HTML5, CSS3, JS et PHPHamdi Hmidi
 
Hybrid Mobile Apps | Ionic & AngularJS
Hybrid Mobile Apps | Ionic & AngularJSHybrid Mobile Apps | Ionic & AngularJS
Hybrid Mobile Apps | Ionic & AngularJSHamdi Hmidi
 
Twitter bootstrap | JCertif Tunisie
Twitter bootstrap | JCertif Tunisie Twitter bootstrap | JCertif Tunisie
Twitter bootstrap | JCertif Tunisie Hamdi Hmidi
 
API Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015
API  Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015 API  Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015
API Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015 Hamdi Hmidi
 
Android initiation
Android initiationAndroid initiation
Android initiationHamdi Hmidi
 

More from Hamdi Hmidi (12)

Getting started with node JS
Getting started with node JSGetting started with node JS
Getting started with node JS
 
Ng init | EPI Sousse
Ng init | EPI SousseNg init | EPI Sousse
Ng init | EPI Sousse
 
Pentaho | Data Integration & Report designer
Pentaho | Data Integration & Report designerPentaho | Data Integration & Report designer
Pentaho | Data Integration & Report designer
 
Ng init
Ng initNg init
Ng init
 
Javascript - Getting started | DevCom ISITCom
Javascript - Getting started | DevCom ISITComJavascript - Getting started | DevCom ISITCom
Javascript - Getting started | DevCom ISITCom
 
Modern web application devlopment workflow
Modern web application devlopment workflowModern web application devlopment workflow
Modern web application devlopment workflow
 
Les Basiques - Web Développement HTML5, CSS3, JS et PHP
Les Basiques - Web  Développement HTML5, CSS3, JS et PHPLes Basiques - Web  Développement HTML5, CSS3, JS et PHP
Les Basiques - Web Développement HTML5, CSS3, JS et PHP
 
Hybrid Mobile Apps | Ionic & AngularJS
Hybrid Mobile Apps | Ionic & AngularJSHybrid Mobile Apps | Ionic & AngularJS
Hybrid Mobile Apps | Ionic & AngularJS
 
Ng-init
Ng-init Ng-init
Ng-init
 
Twitter bootstrap | JCertif Tunisie
Twitter bootstrap | JCertif Tunisie Twitter bootstrap | JCertif Tunisie
Twitter bootstrap | JCertif Tunisie
 
API Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015
API  Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015 API  Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015
API Driven Application - AngulatJS, NodeJS and MongoDB | JCertif Tunisia 2015
 
Android initiation
Android initiationAndroid initiation
Android initiation
 

Les Fondamentaux D'Angular JS | Hmidi Hamdi

  • 2. C’est quoi Angular JS? - AngularJS est un Framework JavaScript open-source développé par Google. - Ce Framework facilite grandement le développement d'application web selon le modèle MVC* (Modèle Vue Controleur). - Utilisée pour développer des applications SPA*(Single Page Application). - Framework des applications coté client.
  • 3. SPA ”Single Page Application”
  • 4. MVC “Model View Controller”
  • 6. Pourquoi Angular JS? - Utilise le modèle MVW (Model View Wathever). - Flexible avec les filtres. - Ecrire moins du code.
  • 7. Hello Angular JS ! <!doctype html> <html ng-app> <head> <title>Hello Angular JS</title> <SCRIPT TYPE="text/javascript" src="JS/angular.min.js"></SCRIPT> </head> <body > <h1> {{« Hello Angular JS» }} </h1> </body> </html>
  • 8. Directives, Filters and Data binding
  • 9. Directives Une directive est une stratégie pour enseigner des nouveaux astuces au HTML. Càd rendre le HTML Dynamique.
  • 10. Exemple <!doctype html> <html> <head> <title>Exemple 1</title> <SCRIPT TYPE="text/javascript" src="JS/angular.min.js"></SCRIPT> </head> <body ng-app> <input type="text" ng-model="name" > <h1>Hello {{name}} </h1> </body> </html> Directive Directive Data Binding
  • 11. Views, Controllers and Scope View Controller$Scope
  • 12. Exemple : View and Controller <!doctype html> <html ng-app > <head> <title>Exemple 2</title> <SCRIPT TYPE = "text/javascript" src= "JS/angular.min.js"></SCRIPT> <script type="text/javascript" src="JS/Controller1.js"></script> </head> <body ng-controller="monContr" > <h1> Membres </h1> <div id = "membre" ng-repeat = "item in items" > <h1>Nom et Prenom : </h1> {{item.nom}} - {{item.prenom}} <h2>Club : </h2> {{ item.club }} </div> </body> </html> function monContr($scope){ $scope.items=[{‘’nom’’:"Hamdi",’’prenom’’:"Hmidi",’’club’’:"IGC" }, {‘’nom’’:"Marwan",’’prenom’’:"Zouinkhi",’’club’’:"IGC"}, {‘’nom’’:"Bouchlema",’’prenom’’:"Sabri",’’club’’:"IGC"}]; }
  • 14. Modules C’est un conteneur d’application , Chaque application web peut être constituée par plusieurs modules chaque module possède ça fonctionnalité. Var myapp= angular.module(‘module_name’,[]); Myapp.controller(‘test’, function($scope){ //TODO code }); <html ng-app=‘’ module_name’’>
  • 15. Events <!doctype html> <html ng-app="myapp"> <head> <title>EVENTS</title> <SCRIPT TYPE="text/javascript" src="angular.min.js"></SCRIPT> <SCRIPT TYPE="text/javascript" src="cont.js"></SCRIPT> </head> <body ng-controller="test"> <form action="#"> <input type="text" ng-model="newval"> <button ng-click="add()">Add</button> </form> <ul> <li ng-repeat="item in items">{{item}}</li> </ul> </body> </html> var myapp=angular.module('myapp',[]); myapp.controller('test',function($scope){ $scope.items=['IGC','SP','MIC','OVET','UGET','UGTE']; $scope.add= function(){ $scope.items.push($scope.newval); $scope.newval=''; } });
  • 17. Routes <!DOCTYPE html> <html ng-app="myapp"> <head> <script src="angular.js"></script> <script src="angular-route.js"></script> <script src="app.js"></script> </head> <body> <div ng-view></div> </body> </html> var myapp = angular.module("myapp", ['ngRoute']); myapp.config( function($routeProvider) { $routeProvider. when('/page1', { templateUrl: 'page1.html', controller: 'page1Ctrl' }). when('/page2/:id', { templateUrl: 'page2.html', controller: 'page2Ctrl' }). otherwise({ redirectTo: '/page1' }); } ); myapp.controller("page1Ctrl", function($scope) { $scope.page = "1"; }); myapp.controller("page2Ctrl", function($scope, $routeParams) { $scope.page = $routeParams.id; });
  • 18. Factories var myapp=angular.module("myapp",[]); myapp.factory("DataFactory",function($http){ var Factory={}; var Response=$http.get("data.json"); Factory.DataGet= function(){ return Response; } return Factory; }); myapp.controller('Ctrl', function($scope,DataFactory){ $scope.tab=[]; DataFactory.DataGet().success(function(dt){ $scope.tab=dt; }); }); [ { "name":"Hamdi", "surname":"Hmidi" }, { "name":"Sabri", "surname":"Bouchlema" } ]
  • 20. Merci pour votre attention