我有一个搜索表单,其中包含下拉字段和下拉选择框数据使用角度js动态显示...现在我想提交此表单并使用角度js在不同的页面中显示结果。
提前致谢!
答案 0 :(得分:1)
使用ng-model
从对象中的表单中收集输入数据。例如:
<select id="one" ng-model="modelData.firstOption" ng-options="item for item in items1"></select>
<select id="two" ng-model="modelData.secondOption" ng-options="item for item in items2"></select>
<button id="searchButton" ng-click="search()">Search</button>
在您的控制器中:
$scope.modelData = {};
$scope.search = function () {
// if you use ngRoute, create URL with parameters. For example:
if (modelData.firstOption && modelData.secondOption) {
window.location.href = 'searchResult/' + modelData.firstOption + '/' + modelData.secondOption;
}
}
// in your routing configuration you must have something like
$routeProvider.when('/searchResult/:firstOption/:secondOption', {
// see https://docs.angularjs.org/api/ngRoute/provider/$routeProvider for more info
}