angularjs - pass an object from controller to another controller anglarjs -


hi i'm new angularjs, can me this: after singup want automatically redirected authentificate page , put login , password in form of authenficate.html

the signupctrl

demoapp.controller('signupctrl',function($scope,$http,$location,user) {      user=$scope.user;     $scope.verification = function(isvalid,user) {          user=$scope.user;          if (isvalid) {             $scope.message = "submitted ";             console.log(user);             console.log(user.type);             if(user.type=="recruteur")             {                 window.alert("bonjour recruteur "+ user.email);                 $location.path("/auth");              }             else {                  window.alert("bonjour condidat "+ user.email);                 $location.path("/auth");             }          } else {             $scope.message = "there still invalid fields below";          }     }; }); 

the singup.html

<body ng-controller="signupctrl">     <form name="registrationform" novalidate           ng-submit="submit(registrationform.$valid)">          <div class="form-group">             <label>email</label>             <input type="email" name="email" class="form-group"                    ng-model="user.email"                    required />         </div>          <div>             <label>password</label>             <input type="password" name="password"                    ng-model="user.password"                    required/>         </div>         <div>             <button type="submit"               ng-click="verification(registrationform.$valid,registrationform.user)">register!</button>         </div>     </form> </body> 

controller authentificate:

demoapp.controller('personctrl',function ($scope, $http,$location,user) {     console.log(user);      var person=user;     $scope.emaill=person.email;     $scope.pwd=person.password;    console.log(person); }); 

authentificate page :

<body> <form>     <input type="text" ng-model="emaill">     <input type="password" ng-model="pwd">     <input type="submit" value="connexion" ng-click="connexion(person)">  </form> </body> 

the route provider

demoapp.config(['$routeprovider',      function($routeprovider){         //systeme de routage         console.log('rederction');         $routeprovider.when ('/auth',{templateurl: 'authentficate.html',             controller: 'personctrl'})              .otherwise({redirectto: 'signup.html'}         );     } ]); 

you can put data needed session in service.

https://docs.angularjs.org/guide/services

but dont put password there, username , authentication token.

check here complete sample token based authentication

https://medium.com/opinionated-angularjs/techniques-for-authentication-in-angularjs-applications-7bbf0346acec


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -