transmettre un paramètre à un itinéraire de via une soumission de formulaire en angular.js
-
20-12-2019 - |
Question
J'essaie de mettre en œuvre une recherche en fonction de certains paramètres.J'ai la vue / la maison et cela consiste à former une forme.Je ne pourrai pas rediriger / éditer le client: / Vue de la clientèle avec ID client.
html ,
<form>
From: <input type="text" name="customernumber"><br>
<a href="#/edit-customer/3">asdasd</a>
</form>
app.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
title: 'Customers',
templateUrl: 'partials/customers.html',
controller: 'listCtrl'
})
.when('/edit-customer/:customerID', {
title: 'Edit Customers',
templateUrl: 'partials/edit-customer.html',
controller: 'editCtrl',
resolve: {
customer: function(services, $route){
var customerID = $route.current.params.customerID;
return services.getCustomer(customerID);
}
}
}).when('/home',{
title: 'home',
templateUrl:'partials/home.html',
}).when('/results',{
title: 'search results',
templateUrl: 'partials/results.html',
})
.otherwise({
redirectTo: '/'
});
}]);
Comment puis-je y parvenir?
La solution
C'est ce que je comprends que vous recherchez, note la directive NG-Modèle sur l'élément d'entrée
<form>
From: <input type="text" ng-model="customerId" name="customernumber"><br>
<a href="#/edit-customer/{{customerId}}">asdasd</a>
</form>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow