Populate (Bind) DropDownList using Entity Framework in AngularJS

Last Reply 16 days ago By SUJAYS

Posted 16 days ago

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

You are viewing reply posted by: SUJAYS 16 days ago.
Posted 16 days 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>