Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

public JsonResult GetdataByID(int Id) { var x = (from n in db.Employees where n.Id == Id select n).FirstOrDefault(); return new JsonResult { Data = x, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }

    public JsonResult GetCountries()
    {
        List<Employee> allCountry = new List<Employee>();
        using (WorkdbEntities dc = new WorkdbEntities())
        {
            allCountry = dc.Employees.OrderBy(a => a.Id).ToList();
        }
        return new JsonResult { Data = allCountry, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
    }

HTML Code

 <div ng-controller="BindData">
        <select ng-model="Id" ng-options="I.Id as I.Id for I in BindId"  ng-change="GetState()">
        <option value="">Select Id</option>
    </select>

    <table>
        <tr>
            <td>Employeename</td>
        </tr>
        <tr ng-repeat="ff in BindTable">
            <td>
                {{ff.Name}}
            </td>

        </tr>
    </table>

</div>

Controller Code

angular.module("MyApp")

    .controller("BindData", function ($scope, LocationId) {

        $scope.BindId = null;
        $scope.Id = null;
        LocationId.GetCountries()
                    .then(function (d) {
                        $scope.BindId = d.data;})$scope.GetState = function (Employee) {LocationId.GetdataByID($scope.Id).then(function (d) $scope.BindTable = d.data;})}})

Factory Code

.factory("LocationId", function ($http) {

var fac = {};

fac.GetCountries = function () {
    return $http.get("/Home/GetCountries")
}
fac.GetState = function (Id) {
    return $http.get("Home/GetdataByID ? Id=" + Id)
}

return fac;})
share|improve this question

I am not even sure what exactly you are trying to do but one thing I noticed that is wrong for sure is:

LocationId.GetdataByID()

You have never defined a GetdataById property/method on your LocationId object.

Please provide more information and try to be more clear with what you are trying to do.

Also, you really need to try to format your questions better if you are expecting someone to help you. Reading code is not always easy as it is, and especially not when you don't invest the effort to make it as easy as possible.

share|improve this answer
    
my aim is i bind Id into dropdownlist when id change that particular data fetch – Md Ghouse Jul 1 at 20:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.