2
我有幾個ons模板在頁面中,每個模板都綁定到它的控制器,現在如何從控制器首先重定向到ons模板second.html成功ajax調用後,下面是我的碼。重定向到從控制器的ons模板
<ons-template id="changePass.html">
<ons-page modifier="shop-details" class='page_bg'>
<ons-toolbar style="background-color: #16A500;">
<div class="left">
<ons-toolbar-button onclick="menu.setMainPage('userProfile.html', {closeMenu: true}), {animation: 'slide'}">
<ons-icon icon="ion-arrow-left-c" size="28px" fixed-width="false"></ons-icon>
</ons-toolbar-button>
</div>
<div class="center">Change Password</div>
</ons-toolbar>
<div ng-controller="userProfile">
<div ng-show="loading" class="loading"><img src="img/loading.gif" height="50px" width="50px"></div>
<div class="profile-card">
<img src="{{profiledata.profile_image_url}}" class="profile-image-settings">
<div class="profile-name">{{profiledata.firstname}} {{profiledata.lastname}}</div>
</div><br>
<div class="form-row">
<input type="password" id="cpass" class="text-input--underbar width-full" placeholder="Current Password" value="">
</div>
<div class="form-row">
<input type="password" id="npass" class="text-input--underbar width-full" placeholder="New Password" value="">
</div>
<div class="form-row">
<input type="password" id="cnpass" class="text-input--underbar width-full" placeholder="Confirm New Password" value="">
</div>
<div class="form-row">
<p style="font-size: small; color: red;">- Must be between 8 and 16 characters long.<br>
- Must contain at least 3 of following.<br>
- English uppercase letter (A to Z).<br>
- English lowercase letter (a to z).<br>
- Numerical digit (0 to 9).<br>
- Special character (#, $, ^, etc.). </p>
</div>
<ons-bottom-toolbar modifier="transparent">
<ons-button modifier="large" class="login-button" ng-click="changePass();">Save</ons-button>
</ons-bottom-toolbar>
</div>
</ons-page>
</ons-template>
$scope.changePass = function(){
var cpass = document.getElementById('cpass').value;
var npass = document.getElementById('npass').value;
var cnpass = document.getElementById('cnpass').value;
$.ajax({
type: 'GET',
url: serviceURL+'account/change_password',
data: {user_id: user_id, authentication_key: authentication_key, current_password: cpass, new_password: npass, confirm_password: cnpass},
timeout: 5000,
success: function (response) {
alert(response);
$scope.loading = false;
$scope.questions = JSON.parse(response).data;
$scope.$apply();
},
error: function (response) {
$scope.error = true;
$scope.$apply();
}
});
};
所以當Ajax請求成功,我想重定向到另一個一些插件模板可以說home.html的。
不以這種方式工作 –
您可以發佈您完全控制? – Munsterlander
更新了完整的代碼。 –