0
I have a search form with 2 selects and 1 Submit:
<select ng-model="marca" ng-options="marca.nome_marca for marca in marcas" ng-change="changeMarca()">
<option value="">Selecione uma Marca</option>
</select>
<select ng-model="modelo" ng-options="modelo.nome_modelo for modelo in modelos|filter:{marca_id:marca.marca_id}" ng-change="changeModelo()">
<option value="">Selecione um Modelo</option>
</select>
<button ng-Click="???">BUSCAR</button>
How can I display the result of this search in another view, more specifically on the route I have already set aside for this: #/busca/:marca_id/:modelo_id
I do not know if I was clear, I already have all the routes, just need to send this to the search controller below:
angular.module("myApp").controller("buscaCtrl", function($scope, $http, $routeParams, estoqueAPI) {
$scope.loading = true;
$scope.buscaMarca = $routeParams.marca_id;
$scope.buscaModelo = $routeParams.modelo_id;
var carregarEstoque = function () {
estoqueAPI.getEstoque()
.success(function (data) {
$scope.carros = data;
}).finally(function() { $scope.loading = false; })
};
carregarEstoque();
});
Afonso! Everything made a lot of sense and really worked. The only thing I still don’t understand why, I’m not getting the $Scope.marca and $Scope.modelo parameter in the formCtrl controller. Any idea why that is? The search result page is all right, I did a manual test with "#/search/35/2736" and all right, but when I do the form comes with values: "#/search/Undefined/Undefined".
– Fábio Duarte
Ops, I was inserting it into the wrong controller. I adjusted it to the correct controller and it’s working 100%. Thank you Afonso!
– Fábio Duarte