我有一个组件(见下文),当路由到使用/ vehicleSearch时,检索一些数据(通过服务'Vehicle')以填充模板vehicle-search-template.html上的下拉框。
angular.
module('vehicleSearch').
component('vehicleSearch', {
templateUrl: 'vehicle-search/vehicle-search.template.html',
controller: ['Vehicle',
function VehicleSearchController(Vehicle) {
this.makes = Vehicle.resource2.query();
}
]
});
模板是一个带有输入框然后是提交按钮的表单。
<div>
<h4>Vehicle Search</h4>
<form ng-submit="searchVehicles()">
<table>
<tr>
<td>VRM: </td>
<td><input type="text" id="vrm" ng-model="vehicleSearchForm.vrm" /></td>
</tr>
<tr>
<td>Make: </td>
<td>
<select ng-options="make.desc for make in $ctrl.makes" ng-model="vehicleSearchForm.make">
<option value="" label="Please select a vehicle make.."/>
</select>
</td>
</tr>
<tr>
<td>Model: </td>
<td>
<select ng-options="model.desc for model in $ctrl.models" ng-model="vehicleSearchForm.model">
<option value="" label="Please select a vehicle model.."/>
</select>
</td>
</tr>
<tr>
<td><input type="submit" value="search"/></td>
</tr>
</table>
</form>
当我提交此表单时,我是否可以在同一组件中处理此提交并重定向到另一个URL,该URL将被路由到另一个组件?如何在控制器中创建另一种方法?