Don't say much nonsense, just look at dry goods.
Use service to share data
Define a service for shared services
//Service of data sharing in household appliance maintenance
angular.module("sqhApp").factory("repairDeviceDataShareServer",function($http,$state,$ionicPopup){
Return {
//Cache the name, quantity and unique identification of the equipment to be repaired currently
deviceRepairObj : [],
//Cell location
xiquLocation:{},
//Appointment time
appointmentDate:{
"Date":
"Time": "
}
//The record of the reservation date interface going back to the previous interface
appointmentBackPage:"",
//Get address fallback interface record
locationBackPage:"",
//Home appliance maintenance description
questionDesc:"",
//Confirm appointment
confirmAppointment : function(resultJson){
var url = "/index.php/Wap/Homemake/createRepairOrder.html";
var p = $http.post(url,resultJson);
p.success(function(response,header,config,status){
//Order submitted successfully
if(response.status == 0){
//Prompt for device selection
var alertPopup = $ionicPopup.alert({
Title: 'home appliance maintenance',
template: response.msg
};
alertPopup.then(function(res) {
$state.go("appliance_index");
};
}else{
//Prompt for device selection
var alertPopup = $ionicPopup.alert({
Title: 'home appliance maintenance',
template: response.msg
};
alertPopup.then(function(res) {
};
}
};
}
//Confirm data submitted by appointment
FormData:{}
}
};
Jump to a new page and inject repairdevicedatashareserver into controller
//Appointment time controller
angular.module("sqhApp").controller("orderDateController", ["$scope", "$state",
'$ionicPopup', 'repairDeviceDataShareServer','appointmentDateService',
function ($scope, $state, $ionicPopup,repairDeviceDataShareServer,appointmentDateService) {
$scope.lists=[];
//Get time from server
appointmentDateService.getAppointmentDateList($scope);
//Back to previous page
$scope.back = function(){
var backPage = repairDeviceDataShareServer.appointmentBackPage;
//If there is no record value, skip to home appliance cleaning service package directory
if(backPage == ""){
$state.go("appliance_index");
}else{
$state.go(backPage);
}
}
//Select time
$scope.selectTime = function(myevent){
var currentObj = $(myevent.target);
currentObj.closest("div.time_list").find(".line_height_35px").removeClass("bg_fdd000 color_e5005a").addClass("bg_ff");
currentObj.addClass("bg_fdd000 color_e5005a").removeClass("bg_ff");
}
//Select date
$scope.selectDate = function(myevent){
var currentObj = $(myevent.target);
currentObj.closest("div.overflow_hidden").find("div.float_left").removeClass("color_e5005a");
currentObj.closest("div.float_left").addClass("color_e5005a");
}
//Confirmation time and date
$scope.confirmDateTime = function(){
var selectObjs = $(".bg_f8f8f8 .color_e5005a");
//Get Date object
var dateObj = $(selectObjs[0]);
if(dateObj.length == 0){
Alert ("please select a date");
return false;
}
//Get time object
var timeObj = $(selectObjs[1]);
if(timeObj.length == 0){
Alert ("please select a time");
return false;
}
//repairDeviceDataShareServer.appointmentDate.date = dateObj;
repairDeviceDataShareServer.appointmentDate.date = "2016-6-6";
repairDeviceDataShareServer.appointmentDate.time = timeObj.html();
This.back ();
}
);
Jump to a new page and reset the data in the Repairdevicedatashareserver
angular.module("sqhApp").controller("applianceIndexController", ["$scope", "$state","repairDeviceDataShareServer","applianceWashShareServer", function ($scope, $state, repairDeviceDataShareServer,applianceWashShareServer) {
//Initialize household appliance maintenance sharing data
repairDeviceDataShareServer.deviceRepairObj = [];
repairDeviceDataShareServer.xiquLocation = {};
repairDeviceDataShareServer.appointmentDate = {"date":"","time":""};
repairDeviceDataShareServer.appointmentBackPage = {};
repairDeviceDataShareServer.locationBackPage = {};
repairDeviceDataShareServer.formData = {};
repairDeviceDataShareServer.questionDesc = "";
//Initialize household appliance cleaning and sharing data
applianceWashShareServer.washType="";
applianceWashShareServer.formData={};
applianceWashShareServer.goodsSelected=[];
);
About this article to share the Angularjs to realize multiple pages to share data way to introduce so many, I hope to help you!