내가 국가, 주 및 도시의 선택 컨트롤을 가지고 있다고 가정 할 때 도시를 바인딩하려는 동안 어떻게 국가와 주 모두의 가치를 얻을 수 있습니까? 내 코드이 코드 지금이angularJS2에서 계단식 작업을 수행하는 방법은 무엇입니까?
bindCountry =() => {
let data = new Array();
let _countries = new Array();
this.location.getCountry().subscribe(_sub => {
data = _sub.json();
}, _error => { },() => {
data.map((value, index, arr) => {
_countries.push(new Country(value["id"], value["name"]));
});
this.countries = _countries;
this.bindDropDown('selCountry', 'countryID', 'Please select Country', 'countryName', this.countries);
});
}
bindState = (x: number) => {
let data = new Array();
let _state = new Array();
this.location.getState(x).subscribe(_sub => {
data = _sub.json();
}, _error => { },() => {
data.map((value, index, arr) => {
if (value['countryId'] == x) {
_state.push(new State(value['countryId'], value['id'], value['name']));
}
});
this.states = _state;
this.bindDropDown('selState', 'StateID', 'Please select State', 'StateName', this.states);
});
}
bindCity = (x: number) => {
var y: any;
let data = new Array();
let _city = new Array();
this.location.getCity(x, y).subscribe(_sub => {
_city = _sub.json();
}, _error => { },() => {
data.map((value, index, arr) => {
debugger;
if (value['countryId'] == x && value['stateId'] == y) {
_city.push(new City(value['countryId'], value['stateId'], value['id'], value['name']));
}
});
this.cities = _city;
this.bindDropDown('selCity', 'CityID', 'Please select City', 'CityName', this.cities);
})
}
처럼, 나는이
<select class="form-control" id="selCountry" (change)="bindState($event.target.value)" disabled></select>
이제 내 문제뿐만 아니라 두 나라의 가치를 얻을 수 있습니다처럼 html 요소에서 상태를 결합 할 수있는 가치를 도시 드롭 다운을 바인딩 할 상태로 어떻게 angularJS2를 사용하여이 작업을 수행 할 수 있습니까?
당신이 당신의 문제를 입증하는 plunker을 만들 수 있을까? – mxii
@mxii 죄송합니다. 나는 작동 할 수있는 플 런커를 만들 수는 없지만 어쨌든 업로드했습니다. https://plnkr.co/edit/QecJfaxkzdhGe3pA7zLK –