----------------------- Page 5-----------------------
AngularJS ? Qu'est ce que c'est ?
AngularJS (site officiel) est un framework JavaScript open-source (rechercher la définition d'open-source et de
framework) développé par Google. Il a été créé par Miško Hevery (en 2010). La version 1.0 (première version dite
stable) date de juin 2012.
Ce framework facilite grandement le développement d'application web selon le modèle MVC (Modèle Vue Controleur).
Nous aurons l'occasion de revenir plus tard sur ces notions, mais vous avez peut-être déjà eu l'occasion d'utiliser des
applications web (souvent appelées «web app»). Par exemple Gmail et GoogleDoc sont des « web app » (site internet
ressemblant à des applications «classiques»).
Notez bien qu'AngularJS n'est pas un "logiciel", vous allez donc produire du code (HTML, JavaScript et CSS).
Première approche
AngularJS va nous permettre de rajouter de nouveaux attributs aux balises HTML, tous ces nouveaux attributs
commenceront par : ng-
Par exemple nous pourrons avoir .......
er
Dans notre 1 exemple nous utiliserons 2 attributs apportés par AngularJS : ng-app et ng-controller, mais il en existe
beaucoup d'autres que nous étudierons plus tard dans ce document.
Nous allons pouvoir introduire ce que nous appellerons pour l'instant des « variables » directement dans le code HTML
(ces « variables » pourront être contrôlées grâce au JavaScript). Ceci va rendre notre page HTML dynamique (les
données affichées pourront évoluer au cours de temps). Ces « variables » seront facilement reconnaissables, car elles
seront encadrées par des accolades : {{maVariable}}
exemple : {{monTitre}}.
Le navigateur n'affichera pas {{monTitre}}, mais la valeur contenue dans la « variable » monTitre.
Un premier exemple
À faire vous même
code HTML ex1.html
Test AngularJS
{{maVariable}}
code JavaScript ex1.js
function monControl($scope){
$scope.maVariable="Hello World !";
}
Quelques remarques sur le contenu de la balise head du fichier HTML :
• Avant de commencer vous devez télécharger le framework sur le site officiel (http://angularjs.org/), choisir
« stable », « Minified » et cliquez sur Download. Récupérer le fichier « angular.min.js».
• La ligne «» va vous permettre d'utiliser AngularJS. À
vous de l'adapter en fonction du dossier qui accueille le fichier « angular.min.js».
• La ligne suivante («») va nous permettre d'accéder à
notre fichier JavaScript «ex1.js», ici aussi, attention au chemin choisi.
Vous avez sans doute remarqué l'attribut ng-app au niveau de la balise body. Cela signifie simplement qu'AngularJS
sera actif de la balise jusqu'à la balise .
L'attribut ng-controller dans la balise va nous permettre de définir un contrôleur. Ce contrôleur sera actif de la
balise jusqu'à la balise . Tout ce qui se trouve entre les balises et sera soumis à la
----------------------- Page 5-----------------------AngularJS? What is this? AngularJS (official site) is an open-source JavaScript framework (look for the definition of open-source and) framework) developed by Google. It was created by Miško Hevery (in 2010). Version 1.0 (first version called stable) of June 2012. This framework facilitates the development of web application according to the MVC (model view controller) pattern. We have the opportunity to come back later on these concepts, but you may already have the opportunity to use the web applications (often referred to as 'web app'). E.g. Gmail and GoogleDoc are of the web app (website similar to "classic" applications). Note that AngularJS is not a "software", you should therefore produce the code (HTML, JavaScript and CSS). First approach AngularJS will allow us to add new attributes to the HTML, all of these new attributes begin by: ng- For example we can have ....... ER In our 1 example we will use 2 attributes provided by AngularJS: ng - app and ng-controller, but there are many others that we will discuss later in this document. We can introduce that for now we will call "variables" directly in the HTML code (these 'variables' may be controlled through JavaScript). This will make our dynamic HTML page (the data displayed may change over time). These 'variable' will be easily recognizable, because they will be framed by curly braces: {{myvariable}} example: {{MyTitle}}. The browser will display not {{MyTitle}}, but the value contained in the "variable" MyTitle. A first example To make you even HTML ex1.html Test AngularJS {{myvariable}} JavaScript ex1.js code function monControl ($scope) {} $scope.maVariable = "Hello World!"; } Some remarks on the content of the HTML head tag: • Before you start you need to download the framework on the official website (http://angularjs.org/), choose 'stable', 'Minified' and click on Download. Retrieve the file 'angular.min.js '. • The line «»» will allow you to use AngularJS. TO you adapt it based on the folder that hosts the file 'angular.min.js '. • The following line («»)«) will allow us to access our JavaScript «ex1.js», here too, attention to the selected path file. You've probably noticed the attribute ng - app at the level of the body tag. This means simply that AngularJS will be active the tag until the tag. The ng-controller in the tag attribute will allow us to define a controller. This controller will be active from the tag to tag . All that stands between the tags and will be submitted to the
번역되고, 잠시 기다려주십시오..
----------------------- ----------------------- Page 5 angularjs? What is it? Angularjs (official site) is an open-source JavaScript framework (look up the definition of open-source and framework) developed by Google. It was created by Miško Hevery (in 2010). Version 1.0 (first version called stable) dated June 2012. This framework greatly facilitates Web application development based on MVC (Model View Controller). We will have occasion to come back later on these notions, but you perhaps already had the opportunity to use web applications (often called "web app"). For example Gmail and GoogleDoc are "web app" (website like "traditional" applications). Note qu'AngularJS is not a "software", you will then generate code (HTML, JavaScript and CSS) . First approach angularjs will allow us to add new attributes to HTML tags, all these new attributes begin by ng- For example we can have
.......
st
In our example we will use 1 2 attributes provided by angularjs: ng-ng and app-controller, but there are
many others which we will study later in this document. We will be able to introduce what we call the moment "variables", directly in the HTML code (the "variables" can be controlled through JavaScript). This will make our dynamic HTML page (the data displayed will change over time). These "variables" are easily recognizable because they will be framed by curly braces: {}} {myVariable example:
{{}} myTitle.
The browser will not show {{}} myTitle but the value contained in the "variable" myTitle. A first example to Do yourself HTML code ex1.html
Test AngularJS
{{}} myVariable
JavaScript ex1.js function monControl ($ scope) {$ scope.maVariable = "Hello World!";} Some remarks on the contents of the head tag of the HTML file: • Before you download the framework on the official website (http://angularjs.org/), choose "stable", "minified" and click Download. Get the "angular.min.js" file. • The line "" will allow you to use angularjs. For you to adapt according to the folder that hosts the "angular.min.js" file. • The next line ("") will allow us to access our JavaScript file "ex1.js" here too careful the chosen path. You might have noticed the app ng-level attribute of the body tag. This simply means qu'AngularJS will be active from the tag to the tag. The ng-check attribute in the tag
will allow us to define a controller. This controller will be active from the
tag to the tag . All that is between the tags and be subjected to
번역되고, 잠시 기다려주십시오..
----------------------- Page 5----- ------ ------ ------
AngularJS? What is it?
AngularJS (official site) is a JavaScript framework open-source (search for the definition of open-source and
framework) developed by Google. It has been created by Miško Hevery (in 2010). 1.0 (First version called
stable) date of June 2012.
This framework greatly facilitates the development of web application according to the MVC (Model View Controller).
We will have the opportunity to return later on these concepts, but you may have already had the opportunity to use the
web applications (often called "web app" ). For example Gmail and GoogleDoc are "web app" (internet site
resembling applications "conventional" ).
HTML 코드 ex1.html
테스트 angularjs< /title> <br /> <script src= "lib/ 각도.js">min </script> <br /> <script src= "javascript/ex1.js" > </script> <br /> </head> <body <br /> NG-app> <br /> <h1 NG- 컨트롤러= " moncontrol" > {{myvariable}} < /h1> <br /> < /body> </html <br /> <br /><br />> JavaScript 코드 ex1.js moncontrol <br /><br /> 기능( ) 달러 범위) { <br />$ 범위.myvariable= " Hello World! "; <br /></span>Note Although AngularJS is not a "software", you will therefore produce code (HTML, JavaScript, and CSS).
First approach
AngularJS will allow us to add new attributes to HTML tags, all these new attributes
will begin by: ng-
For example we can have ....... < /p>
er
This will make our dynamic HTML page (the
data displayed will evolve in the course of time). These "variables" will be easily recognizable, because they
will be framed by curly braces: { {MYVARIABLE}}
example: { {montitre} } < /h1 >.
The browser does not display { {montitre} }, but the value contained in the "variable" montitre.
A prime example
to make you even
In our 1 example we will use 2 attributes made by AngularJS: ng-app and ng-controller, but there are
a lot of other that we will consider later in this document.
We are going to be able to introduce what we call for the moment of "variables" directly in the HTML code
(these "variables" can be controlled with the JavaScript).HTML code ex1.html
< !DOCTYPE html>
Test AngularJS< /title> <br /> <script src= "lib/angular.min. js" > < /script> <br /> <script src= "javascript/ex1.js" > < /script> <br /> < /head> <br /> <body ng-app> <br /> <h1 ng-controller= "moncontrol" > { {MYVARIABLE} } < /h1> <br /> < /body> <br /> < /html> <br /><br />JavaScript code ex1.js <br /><br />function moncontrol( $scope){ <br /> $scope.MYVARIABLE= "Hello World! "; <br /></span>}
A few remarks on the content of the head tag of the HTML file:
• Before you begin You must download the framework on the official site (http://angularjs.org/), choose
"stable", "Minified" and click Download. Retrieve the file "angular.min. js".
• The line " " will allow you to use AngularJS. TO
Will be active for the tag until the tag < /body>.
The attribute ng-controller in the tag will allow us to define a controller. This controller will be active in the
tag until the tag < /h1 >. Everything that is located between the tags and < /h1> will be submitted to the
번역되고, 잠시 기다려주십시오..