I am able to populate 2 dropdowns directly from database. My problem is, the 2nd dropdown values has to be populated based on the 1st dropdown selection. Since i am new to Angular, i m not able to figure that out, can someone help me out with this.
<select id="OfficeId" name="OfficeId" ng-model="item.OfficeId"
ng-options="item.OfficeId as item.OfficeName for item in Offices">
<option value="" selected>Select the Office</option>
</select>
<select id="OBJ" name="OBJ" ng-model="item.OfficeOBJId"
ng-options="item.OfficeOBJId as item.OBJId for item in Codes">
<option value="" selected>Select OBJ Code</option>
</select>
myApp.factory('OfficeNames', function ($resource) {
return $resource(
'api/Office/:id',
{ id: '@id' },
{ update: { method: 'PUT' } }
);
});
myApp.factory('OfficeObjCode', function ($resource) {
return $resource(
'api/OfficeObj/:id',
{ id: '@id' },
{ update: { method: 'PUT' } }
);
});
function OfficeCtrl($scope, $location, OfficeNames) {
$scope.Offices = OfficeNames.query();
}
function OfficeObjCtrl($scope, $location, OfficeObjCode) {
$scope.Codes = OfficeObjCode.query();
}
Note: I am using Web API/Angular/Petapoco/SQL Server
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…