Ajout exo services
This commit is contained in:
23
javascript/angular/exercices/services-2/app.js
vendored
Normal file
23
javascript/angular/exercices/services-2/app.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Énoncé:
|
||||
* Implémenter le service "myPrompt" qui pose une question et retourne la réponse entrée par l'utilisateur.
|
||||
* Le service devra lui même utiliser le service $window, service "alias" de l'objet Window fourni par Angular et sa méthode
|
||||
* prompt().
|
||||
*
|
||||
* Documentation:
|
||||
* - Service $window: https://code.angularjs.org/1.3.15/docs/api/ng/service/$window
|
||||
* - window.prompt(): https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
var Exo = angular.module('Exo', []);
|
||||
|
||||
Exo.controller('MainCtrl', ['$scope', /*'myPrompt',*/ function($scope /*,myPrompt*/) {
|
||||
|
||||
$scope.question = 'Quel est votre age ?';
|
||||
$scope.response = '--';
|
||||
|
||||
// scope.response = myPrompt.ask($scope.question);
|
||||
|
||||
}]);
|
20
javascript/angular/exercices/services-2/index.html
Normal file
20
javascript/angular/exercices/services-2/index.html
Normal file
@ -0,0 +1,20 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<title>Exercice: création de service</title>
|
||||
</head>
|
||||
<!-- Déclaration de l'application -->
|
||||
<body ng-app="Exo">
|
||||
|
||||
<div ng-controller="MainCtrl">
|
||||
<label>Question</label>
|
||||
<input type="text" ng-model="question" />
|
||||
<br />
|
||||
<b>Votre réponse:</b> <span>{{ response }}</span>
|
||||
</div>
|
||||
|
||||
<!-- Import de du framework Angular -->
|
||||
<script src="../node_modules/angular/angular.js"></script>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user