我正在尝试在级联选择元素中设置模型的初始值。
所有模型都有初始值。视图是这样的:
**1)** <select id="ddN_Universitate" ng-model="CandidatInfo.ID_N_UniversitateAbsolvita" ng-change="N_FACULTATEListByN_UNIVERSITATE(CandidatInfo.ID_N_UniversitateAbsolvita)" ng-options="u.ID_ELEMENT as u.DENUMIRE for u in ListN_UniversitatiInfo">
<option value=''>Selecteaza</option>
</select>
<br />
**2) depends on 1)**
N_Facultate {{CandidatInfo.ID_N_FacultateAbsolvita}}
<select id="ddN_Facultate" ng-model="CandidatInfo.ID_N_FacultateAbsolvita" ng-change="N_PROGRAM_DE_STUDIUListByN_FACULTATE(CandidatInfo.ID_N_FacultateAbsolvita)" ng-options="f.ID_ELEMENT as f.DENUMIRE for f in ListN_FacultatiInfo">
<option value=''>Selecteaza</option>
</select>
<br />
**3) depends on 2)**
N_Program {{CandidatInfo.ID_N_ProgramStudiuAbsolvit}}
<select id="ddN_ProgramStudiu" ng-model="CandidatInfo.ID_N_ProgramStudiuAbsolvit" ng-options="p.ID_ELEMENT as p.DenumireCompletaRMU for p in ListN_PROGRAM_DE_STUDIUInfo">
<option value=''>Selecteaza</option>
</select>
对于id =“ddN_Universitate”,设置了值,但对于以下选择,未设置模型中的值,因为它们依赖于调用“ng-change”事件处理程序。
控制器是这样的:
$scope.LoadUniversitati = function () {
factoryRMU.callGetService("N_UNIVERSITATE/N_UNIVERSITATEListByAnUniversitar?iD_AnUniv=" + $id_anuniv)
.then(function (response) {
var fullResult = angular.fromJson(response);
//var CandidatInfo = JSON.parse(fullResult.data);
$scope.ListN_UniversitatiInfo = fullResult.data;
},
function (data) {
console.log("Unknown error occurred calling N_UNIVERSITATEListByAnUniversitar");
console.log(data);
});
};
$scope.N_FACULTATEListByN_UNIVERSITATE = function (iD_UNIVERSITATE) {
factoryRMU.callGetService("N_FACULTATE/N_FACULTATEListByN_UNIVERSITATE?iD_UNIVERSITATE="+ iD_UNIVERSITATE + "&iD_AnUniv=" + $id_anuniv)
.then(function (response) {
var fullResult = angular.fromJson(response);
//var CandidatInfo = JSON.parse(fullResult.data);
$scope.ListN_FacultatiInfo = fullResult.data;
},
function (data) {
console.log("Unknown error occurred calling N_FACULTATEListByN_UNIVERSITATE");
console.log(data);
});
};
$scope.N_PROGRAM_DE_STUDIUListByN_FACULTATE = function (iD_Facultate) {
factoryRMU.callGetService("N_PROGRAM_DE_STUDIU/N_PROGRAM_DE_STUDIUListByN_FACULTATE?iD_ELEMENT=" + iD_Facultate + "&iD_AnUniv=" + $id_anuniv)
.then(function (response) {
var fullResult = angular.fromJson(response);
//var CandidatInfo = JSON.parse(fullResult.data);
$scope.ListN_PROGRAM_DE_STUDIUInfo = fullResult.data;
},
function (data) {
console.log("Unknown error occurred calling N_PROGRAM_DE_STUDIUListByN_FACULTATE");
console.log(data);
});
};
$scope.LoadUniversitati();
那么,有可能吗?
谢谢。
答案 0 :(得分:0)
试试这个
<select id="ddN_Universitate" ng-model="CandidatInfo.ID_N_UniversitateAbsolvita" ng-change="N_FACULTATEListByN_UNIVERSITATE(CandidatInfo.ID_N_UniversitateAbsolvita)">
<option value=''>Selecteaza</option>
<option ng-repeat="u in ListN_UniversitatiInfo" value="{{u.ID_ELEMENT}}">{{u.ELEMENT_LABEL}}</option>
</select>