Populate (Bind) DropDownList using Entity Framework in AngularJS

Last Reply one year ago By SUJAYS

Posted one year ago

How to populate the dropdownlist using entity framework in angular js?

You are viewing reply posted by: SUJAYS one year ago.
Posted one year ago

 Bind Dropdownlist using angularjs 

public JsonResult GetAllLatereason()
{
    using (Latereason_INGEntities Obj = new Latereason_INGEntities())
    { 
        List<LateReason> Late = Obj.LateReasons.ToList();
        return Json(Late, JsonRequestBehavior.AllowGet);
    }
}

 

$scope.GetAllLatereason = function () {
    $http({
       method: "get",
       url: "http://localhost:62537/Package/GetAllLatereason"})
       .then(function (response) {
           $scope.Late_INGEntities = response.data;
       }, function () {
           alert("Error Occur");
    })
};
<div class="col-sm-4 p-0">
    <select ng-model="Locations" ng-options="location.Code as location.LocationDescription for location in Location_INGEntities" ng-init="GetAllLocation()" class="w-100 form-control"></select>
</div>