2016-03-22 43 views
-1

bağlayamıyorum İyonik çalışıyorum ve günlükleri görmek için Ubuntu ve chrome kullanmak ve burada veri bir nesneyi girer hangi veri bağlamaya çalışıyorum kullanıcı girilen değeri sunucuya gönderebilir.iki yönlü veri bağlama angularjs denetleyici tarafında

benim html görünüyor burada

<ion-modal-view ng-controller="SignInCtrl"> 
    <ion-header-bar> 
    <button class="button ion-chevron-left" ng-click="signUpBack()" >Back</button> 
    <div class="h1 title">Form Validation</div> 
    </ion-header-bar> 
    <ion-content> 
    <div class="list"> 
     <label class="item item-input item-stacked-label"> 
     <span class="input-label">UserName</span> 
     <input type="text" placeholder="John" data-ng-model="formUserName"> 
     </label> 
     <label class="item item-input item-stacked-label"> 
     <span class="input-label">Name</span> 
     <input type="text" placeholder="Suhr" data-ng-model="formName"> 
     </label> 
     <label class="item item-input item-stacked-label"> 
     <span class="input-label">Email</span> 
     <input type="text" placeholder="[email protected]" data-ng-model="formEmail"> 
     </label> 
     <label class="item item-input item-stacked-label"> 
     <span class="input-label">Password</span> 
     <input type="text" placeholder="sdftw" data-ng-model="formPassword"> 
     </label> 
    </div> 

    <button class="button button-block button-positive" ng-click="createUser()"> 
     Create Account 
    </button> 
    </ion-content> 
</ion-modal-view> 

ve benim denetleyicisi gibi ben formPost değişkeni kullanıcının girdiği değeri bağlama çalışıyorum benim formPost kontrol ediniz.

app.controller('SignInCtrl',['$scope','$http','$state',function($scope,$http,$state){ 
    console.log('invoking SignInCtrl'); 

    $scope.signUpBack = function(){ 
    $state.go('details'); 
    }; 

    $scope.createUser = function(){  

    var formPost = { 
     "Username":$scope.formUserName, 
     "Name":$scope.formName, 
     "EmailID":$scope.formEmail, 
     "Password":$scope.formPassword 
    }; 
    console.log(formPost); 

    $http.post("http://aflaree.com/qrcodeservice/Service1.svc/Signupsupervisor", formPost) 
     .success(function(response){ 
     console.log(response); 

     if(!response.Response){ 
     alert(response.Response); 
     $state.go('login'); 
     } 
     else{ 
      alert('error'); 
     } 
     }) 
     .error(function(response){ 
     console.log(response); 
     alert(' error Username already exist'); 
     }); 
    }; 
}]); 

console.log içinde (formPost); undefined değer alıyorum ama herhangi bir fikirde kullanıcı girilen değere ihtiyacım var.

Teşekkür

+0

karşılaştığınız herhangi bir hata? – Webruster

+0

hala hata yok –

+0

Konsolda kontrol et – Webruster

cevap

0

Bunu basitleştirmek olabilir:

app.controller('SignInCtrl',['$scope','$http','$state',function($scope,$http,$state){ 
 
    console.log('invoking SignInCtrl'); 
 

 
    $scope.signUpBack = function(){ 
 
    $state.go('details'); 
 
    }; 
 

 
    $scope.createUser = function(form){  
 

 
    console.log(form); 
 

 
    $http.post("http://aflaree.com/qrcodeservice/Service1.svc/Signupsupervisor", form) 
 
     .success(function(response){ 
 
     console.log(response); 
 

 
     if(!response.Response){ 
 
     alert(response.Response); 
 
     $state.go('login'); 
 
     } 
 
     else{ 
 
      alert('error'); 
 
     } 
 
     }) 
 
     .error(function(response){ 
 
     console.log(response); 
 
     alert(' error Username already exist'); 
 
     }); 
 
    }; 
 
}]);
<ion-modal-view ng-controller="SignInCtrl"> 
 
    <ion-header-bar> 
 
    <button class="button ion-chevron-left" ng-click="signUpBack()" >Back</button> 
 
    <div class="h1 title">Form Validation</div> 
 
    </ion-header-bar> 
 
    <ion-content> 
 
    <div class="list"> 
 
     <label class="item item-input item-stacked-label"> 
 
     <span class="input-label">UserName</span> 
 
     <input type="text" placeholder="John" data-ng-model="form.UserName"> 
 
     </label> 
 
     <label class="item item-input item-stacked-label"> 
 
     <span class="input-label">Name</span> 
 
     <input type="text" placeholder="Suhr" data-ng-model="form.Name"> 
 
     </label> 
 
     <label class="item item-input item-stacked-label"> 
 
     <span class="input-label">Email</span> 
 
     <input type="text" placeholder="[email protected]" data-ng-model="form.Email"> 
 
     </label> 
 
     <label class="item item-input item-stacked-label"> 
 
     <span class="input-label">Password</span> 
 
     <input type="text" placeholder="sdftw" data-ng-model="form.Password"> 
 
     </label> 
 
    </div> 
 

 
    <button class="button button-block button-positive" ng-click="createUser(form)"> 
 
     Create Account 
 
    </button> 
 
    </ion-content> 
 
</ion-modal-view>

+0

Ben oturum açma formu için iyi çalıştığını aynı yöntemi kullanıyordum ama bu formda çalışmıyor neden olduğunu biliyorum ben bu formda çalışmıyor –

+0

Dürüst olmak gerekirse ben de yerel olarak bana iyi çalışır! – Bettimms

+0

https://plnkr.co/edit/Ol244At5Yd4RMyuoChA4 Lütfen bunu konsol.log üzerinde kontrol edin. Kullanıcının nesne formumdaki veriyi göremiyorum. –

İlgili konular