$scope.encryptSend = function(payload, tempPwd){
var local = payload;
local.password = Encryption.encrypt(tempPwd);
local.confirm_password = local.password;
$http.post('REST API URL', local).success(function(response) {
CommonService.setLogin(true);
$state.go('home.bookings');
});
}
$scope.doRegister = function() {
var tempPwd = $scope.signUpData.password;
var tempCPwd = $scope.signUpData.confirm_password;
var data = $scope.signUpData;
if ($scope.signUpData.tc) {
if ($scope.signUpData.password === $scope.signUpData.confirm_password) {
var payload = data;
$scope.encryptSend(payload, tempPwd);
}
}
};
下面是HTML代碼:解耦AngularJS範圍從局部變量變量值值
<ion-view title="Signup" id="page6" class=" ">
<ion-content padding="true" class="has-header">
<form id="signup-form3" class="list ">
<ion-list id="signup-list3" class=" ">
<label class="item item-input item-floating-label" id="signup-input3">
<span class="input-label">Business Name</span>
<input type="text" placeholder="Business Name" ng-model="signUpData.business_name">
</label>
<label class="item item-input item-floating-label" id="signup-input4">
<span class="input-label">Username</span>
<input type="text" placeholder="Username" ng-model="signUpData.username">
</label>
<label class="item item-input item-floating-label" id="signup-input5">
<span class="input-label">Password</span>
<input type="password" placeholder="Password" ng-model="signUpData.password">
</label>
<label class="item item-input item-floating-label" id="signup-input6">
<span class="input-label">Confirm Password</span>
<input type="password" placeholder="Confirm Password" ng-model="signUpData.confirm_password">
</label>
<label class="item item-input item-floating-label" id="signup-input6">
<span class="input-label">Email Id</span>
<input type="email" placeholder="Email Id" ng-model="signUpData.emailId">
</label>
<label class="item item-input item-floating-label" id="signup-input6">
<span class="input-label">Mobile Number</span>
<input type="number" placeholder="Mobile Number" ng-model="signUpData.mobileNo">
</label>
<ion-checkbox ng-model="signUpData.tc">I agree to the Terms & Conditions</ion-checkbox>
</ion-list>
<button id="signup-button3" class=" button button-positive button-block " ng-click="doRegister()">Sign up
</button>
</form>
</ion-content>
</ion-view>
我試圖加密密碼,並將其發送到REST API。但是,當我單擊提交時,表單中的密碼文本字段會顯示加密的密碼。
我已將整個數據複製到一系列局部變量中。但$ scope.signupdata仍然以某種方式反映了加密文本。而且我無法將$ scope.signupdata中的加密文本解耦。
您能否讓我知道我在這裏做錯了什麼。
謝謝你做到了。我忘記了通過引用複製的對象。 –