Angular.js의 양식 제출을 통해 경로로 매개 변수 전달
-
20-12-2019 - |
문제
나는 특정 매개 변수를 기반으로 검색을 구현하려고합니다.나는 / 집이 있고 그것은 양식을 구성합니다.고객 ID를 사용하여 / 고객 ID보기로 리디렉션 / 고객 ID로 리디렉션하지 않을 것입니다.
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-Model 지시문
<form>
From: <input type="text" ng-model="customerId" name="customernumber"><br>
<a href="#/edit-customer/{{customerId}}">asdasd</a>
</form>
. 제휴하지 않습니다 StackOverflow