在这种离子应用程序,我想从搜索页面中输入数据,并显示在下一页的结果。但是,当我尝试它不会工作。我可以将搜索结果发送到控制台。并且数据也不会传递到下一页,即使我为这两个页面创建了相同的控制器。请帮我解决这个问题!谢谢!!我如何获得一个搜索页面的搜索结果进入下一个页面,并显示
这是我的按钮的代码( 'searchA' 是包含输入数据的对象)
<button type="button" class="button button-block button-positive" ng-click="search(searchA)" ui-sref="app.MainSearchResult">Search</button>
这些是我的状态(app.js文件)
.state('app.MainSearch', {
cache:false,
url: '/MainSearch',
views: {
'menuContent': {
templateUrl: 'templates/MainSearch.html',
controller: 'MainSearchCtrl'
}
}
})
.state('app.MainSearchResult', {
url: '/MainSearchResult,
views: {
'menuContent': {
templateUrl: 'templates/MainSearchResult.html',
controller: 'MainSearchResultCtrl'
}
}
})
这是我的搜索功能( controller.js)
$scope.search = function(searchA){
console.log('No : '+ searchA.emp_EPF);
console.log('Name : '+ searchA.emp_Name);
console.log('Company :'+ searchA.emp_Comp);
//console.log('qualification Type : ' + emp_qualiType);
console.log('-------------------');
$http({
method: 'GET',
url: 'http://localhost/mas/Search.php',
params: {employeeNo : searchA.emp_EPF,
employeeName : searchA.emp_Name,
employeeCompany : searchA.emp_Comp,
employeeBusinessUnit : searchA.emp_BU,
employeeTeamName : searchA.emp_Team,
employeeSecondaryCompany : searchA.emp_secondmant,
employeeRelatedEmployee : searchA.emp_relatedEmp,
employeeWorkLevel : searchA.emp_workl,
employeeDesignationName : searchA.emp_designation,
qualificationType : searchA.emp_qualiType,
qualificationField : searchA.emp_qualiField,
programName : searchA.emp_progName,
serviceProvider : searchA.emp_svcProvider
}
}).then(function successCallback(response) {
$scope.searchResults = response.data['records'];
console.log('success :'+ JSON.stringify($scope.searchResults));
}, function errorCallback(response) {
console.log('error',response);
// called asynchronously if an error occurs
// or server returns response with an error status.
});
angular.copy($scope.resetData,searchA);
}
这是我的下一页的结果集视图。
<ion-list ng-repeat="x in searchResults">
<ion-item class="item item-text-wrap" >
<div >
<h2>{{x.employeeNo}}</h2>
<p>{{x.employeeName}}</p>
<div>
<a class="button button-outline button-medium button-positive" >Edit</a>
</div>
</div>
</ion-item>
</ion-list>
请帮助我做到这一点! 谢谢!
你有什么问题不能理清?什么是控制台输出? – boroboris
当我把结果传递给相同页面(搜索页面)的控制台时,它显示为它应该作为JSON对象。 我不能把搜索到的查询的结果集到下一页(搜索结果页面)! 我需要知道如何将这些结果带到下一页(搜索结果页面) –