Here is my plunk :  http://plnkr.co/edit/n80yLO4cgGAEu5whUVcM?p=preview

Le lundi 17 mars 2014 15:21:03 UTC+1, Kévin Ribot a écrit :
>
> Hello,
>
> I begin with AngularJS, after a lot of tests i come here to ask help ..
>
> I search to send parameters using method $http.get() to get some data :
>
>
> *My controller : *
>
>
> *angular.module*('app')
> *.controller*('MainCtrl',['$rootScope','$scope','$location','Auth','toaster', 
> function ($rootScope, $scope, $location, Auth, toaster) {
>
>
>     //click on "Connect" button
>    * $scope.connexion* = *function *() {
>         Auth.authentification({
>                 login: $scope.login,
>                 password: $scope.password,
>                 token : "5545e"
>             },
>             f*unction (success)* {
>                 //pop('Succès','Vous êtes maintenant authentifié !');
>              //   console.log("yes");
>                 $location.path('/prestataire/1');
>             },
>             *function (error)* {
>                 $rootScope.error = 'Authentification failed';
>             });
>     };
>
>    
> }]);
>
>
> *My JSON file*
>
> {
>     "login": "kev",
>     "password": "hello",
>     "token": "54eaelome5"
> }
>
>
> *My service :*
>
> *angular.module*('app')
>     .*factory*('Auth', ['$http', '$rootScope', function ($http, 
> $rootScope) {
>         
>   
>         function changeUser(user) {
>             $rootScope.user = user;
>         }
>
>         return {
>             *authentification*: *function *(user, success, error) {
>                  
>                * $http.get*('data/login.json', user)
>                 *.*success(function (user) {
>                     changeUser(user);
>                     success(user);
>                 })
>                 *.*error(function(){
>                     console.log("Error !");
>                 });
>             }
>         };
>
>     }]);
>
>
> My view :
>
>  <form name="formulaireConnexion" novalidate>
>                <span class="title">Login: </span>
>              <input ng-model="login" required>
>              <br>
>              <br>
>              <span class="title">Password: </span>
>              <input  type="password" ng-model="password" required >
>
>              <div class="clear"></div>
>              <button type="button"  class="btn btn-default bt_connexion" 
> ng-click="connexion()">Connect</button>
>   </form>
>
>
> The *reponse *is* every true*/*success *! Even when I send false 
> parameter (ex : login : "toto" )
>
> Thanks for your help :)
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to