angular.jsのフォーム送信からのルートにパラメータを渡す
-
20-12-2019 - |
質問
特定のパラメータに基づいて検索を実装しようとしています。私はビュー/ホームを持っていて、それはフォームです。カスタマーIDを使用して/ CustomerIDビューを/ edit-customerにリダイレクトすることはできません。
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: '/'
});
}]);
.
これを達成するにはどうすればいいですか?
解決
これは私があなたが探している理由です、入力要素のNGモデル指令
<form>
From: <input type="text" ng-model="customerId" name="customernumber"><br>
<a href="#/edit-customer/{{customerId}}">asdasd</a>
</form>
. 所属していません StackOverflow