Bonsoir a tous,
s'il vous plaît j'ai cette erreur en angularjs "signupService is not defined" pourtant je crois avoir fait les injections correctement. ça affiche cette erreur lorsque je fais appel a la ligne 14 dans le controller.js:
J'ai parcouru plusieurs tutos sans succès. Si quelqu'un a une idée, merci de la proposer.
Code : Sélectionner tout - Visualiser dans une fenêtre à part signupService.saveRegistration($scope.registration)
Voici mes codes:
app.js
controller.js
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 angular .module('signupApp', ['ngRoute']) .config(config); config.$inject = ['$routeProvider', '$locationProvider']; function config($routeProvider, $locationProvider) { $routeProvider .when('/', { templateUrl: '../views/register.html' }).when('/login', { templateUrl: '../views/login.html' }).otherwise({ redirectTo: '/' }) };
index.html
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 'use strict'; angular .module('signupApp') .controller('signUpController', ['$scope', '$window', '$location', 'signupService', function ($scope, $window, $location, signupService) { $scope.registration = { Email: "", Password: "", ConfirmPassword: "" } $scope.signUp = function () { signupService.saveRegistration($scope.registration).then(function () { console.log("succes enregistrement"); }, function () { console.log("echec enregistrement"); }) } }]) .factory('signupService', function ($http) { signupService = {}; signupService.saveRegistration = function (data) { return $http.post('http://localhost:78596/api/Account/Register', data); } return signupService; })
Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 <!DOCTYPE html> <html ng-app="signupApp"> <head> <meta charset="utf-8" /> <title></title> <link href="Content/bootstrap.min.css" rel="stylesheet"> </head> <body> <div class="container"> <div ng-view></div> </div> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular-route.min.js"></script> <script src="Scripts/jquery-1.9.1.js"></script> <script src="app/app.js"></script> <script src="app/controller.js"></script> </body> </html>
Partager