1

사용자가 양식에 입력 한 데이터를 저장할 수 없습니다. 이것은 각 단계가 각도 UI 라우터를 사용하여보기로 포함 된 다단계 형식입니다. 데이터를 저장해야하는 객체를 기록했지만 비어 있습니다. 그래서 난 그냥 하나를 게시하고Angular.js UI 라우터를 사용하여 작성된 다중 단계 데이터의 데이터를 저장할 수 없습니다.

var app = angular.module("Signup", ['ui.router', "ngAnimate"]); 

app.config(function($stateProvider,$urlRouterProvider) { 
    $urlRouterProvider.otherwise('/index/signup'); 
    $stateProvider 
    .state('index', { 
    url: '/index', 
    templateUrl: 'index.html', 
    controller: 'FormCtrl' 
    }) 
    .state('index.signup', { 
    url: '/signup', 
    templateUrl: 'views/signup.html', 
    controller: 'FormCtrl' 
    }) 
    .state('index.otp', { 
    url: '/otp', 
    templateUrl: 'views/otp.html', 
    controller: 'FormCtrl' 
    }) 
    .state('index.password', { 
    url: '/password', 
    templateUrl: 'views/password.html', 
    controller: 'FormCtrl' 
    }) 
    .state('index.identity', { 
    url: '/identity', 
    templateUrl: 'views/identity.html', 
    controller: 'FormCtrl' 
    }) 
    .state('index.done', { 
    url: '/done', 
    templateUrl: 'views/done.html', 
    controller: 'FormCtrl' 
    }); 
}); 
app.controller("FormCtrl", ["$scope", "$location", "$window", "dataService", function($scope, $location, $window, dataService) { 
    $scope.newuser = dataService.newuser; 
    if(document.getElementById('showPswd')) { 
     document.getElementById('showPswd').addEventListener("click", function() { 
      var pwd = document.getElementById("newPassword"); 
      if (pwd.getAttribute("type") === "password") { 
       pwd.setAttribute("type", "text"); 
      } else { 
       pwd.setAttribute("type", "password"); 
      } 
     }); 
    } 
    if(document.getElementById('last')) { 
     console.log(dataService.newuser.firstname); 
      setTimeout(function() { 
      $window.open('http://www.ayushdevelops.com/'); 
      }, 10000); 
    } 

    $scope.go = function(path) { 
     $location.path(path); 
    }; 
}]); 

app.factory('dataService', function() { 
    return { 
    newuser: {} 
    }; 
}); 

내 모든보기이 페이지를 채울 싶지 않아요.

 <div id="wrapper-signup"> 
     <h1>Borrower Signup</h1> 
     <p>Register and start borrowing money online.</p> 

     <div class="element-wrap"> 
     <label>NAME<br> 
      <div class="name-wrap"> 
      <input type="text" ng-model="newuser.firstname" name="firstname" id="firstname" value="" placeholder="First Name"> 
      <input type="text" ng-model="newuser.lastname" name="lastname" id="lastname" value="" placeholder="Last Name"> 
      </div> 
     </label><br> 
     </div> 
     <div class="element-wrap"> 
      <label for="email">EMAIL 
      <div class="email-num-wrap"> 
       <span class="awesome-icon"><i class="fa fa-envelope-o fa-lg email-icon" aria-hidden="true"></i></span><input type="email" id="email" ng-model="newuser.email" name="email" value="" placeholder="Email ID" required> 
      </div> 
      <p class="error" style="color: red; font-size: 0.8em;" ng-show="signForm.email.$invalid && signForm.email.$dirty">Enter a valid email</p> 
      </label> 
     </div> 
     <div class="element-wrap"> 
     <label>MOBILE NUMBER 
      <div class="email-num-wrap"> 
      <span class="awesome-icon"><i class="fa fa-mobile fa-2x mobile-icon" aria-hidden="true"></i></span><input type="number" id="number" ng-model="newuser.number" name="mobile-number" value="" placeholder="Enter 10 digit number"> 
      </div> 
     </label> 
     </div> 
     <div class="clear"> 
     &nbsp; 
     </div> 
     <div class="checkbox-wrap"> 
     <input type="checkbox" class="checkbox" name="terms" value="" ng-model="tcheck" required><p class="checkbox-text">I have read and agree to the <a href="#">Privacy Policy</a>, <a href="#">Terms of Use</a> and consent to Electronic Disclosures.</p> 
     </div> 
     <div class="checkbox-wrap"> 
     <input type="checkbox" class="checkbox" name="condiiton" value="" ng-model="ccheck" required><p class="checkbox-text">I authorize RupaiyaExchange to share my details with other Financial Institutions for credit card check and faster processing of loan.</p> 
     </div> 
     <a ui-sref='index.otp' ng-show="signForm.email.$valid && tcheck && ccheck" class="submit-signup">SIGNUP</a> 

    </div> 
+0

서비스가 그 시점에서 정확한 데이터를 가지고있는 경우'을 console.log (dataService.newuser)를 넣어보십시오'$의 scope.newuser''에 할당하기 전에 확인합니다. – georgeawg

답변

0

각보기 FormCtrl을 다시 초기화하고 '완료'마지막 뷰에서 데이터를해야합니다 있도록이 범위의, 내가 마지막 뷰가 모델이 비어있는 이유 데이터를 제공하지 않습니다 가정, 데이터를 저장하려고 in rootScope

+0

그들은 서비스를 사용하고 있습니다. – daveyfaherty

0

아마 정의되지 않은 속성에 모델을 바인딩하고 있습니까? ng-model은 괜찮습니까?

공장에서 각 속성을 설정하여 도움이되는지 확인해보십시오.

예 :

app.factory('dataService', function() { 
    return { 
    newuser: { 
     firstName: '', 
     lastName: '' 
    } 
    }; 
}); 
+0

아니요. 도움이되지 않았습니다. 속성이있는 객체가 있습니다. –

+0

newuser.fruit = 'banana'와 같은 속성을 추가하는 경우이 속성을보기에 인쇄 할 수 있습니까? – daveyfaherty

+0

예, 내 콘솔에 로그인되어 있습니다. 빈 속성의 나머지와 함께. –