Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. AngularJS: ng-repeat not printing data coming from asp.net mvc action

AngularJS: ng-repeat not printing data coming from asp.net mvc action

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netannouncementlearningjavascript
1 Posts 1 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mou_kol
    wrote on last edited by
    #1

    Hi i am learning angularjs.i am using AngularJs version v1.8.2 and VS2013 IDE. i am trying to call asp.net mvc action from angularjs controller and print data in page by ng-repeater. ng-repeater not printing any data. This is my asp.net mvc action

    public ActionResult GetData(string p1)
    {
    List crs = new List();
    crs.Add(new course { Name = "C#" });
    crs.Add(new course { Name = "VB.Net" });
    crs.Add(new course { Name = "SQL" });
    crs.Add(new course { Name = "RDBMS" });
    return Json(crs, JsonRequestBehavior.AllowGet);
    }

    This is my angularjs controller from where i am calling asp.net mvc action.

    var myApp = angular.module("MyApp", []);
    myApp.controller('myController', function ($scope, $http) {
    $scope.Update = function (p1) {
    $http({
    url: '/Home/GetData?p1='+p1,
    method: 'GET'
    })
    .then(function (response) {
    console.log(response.data);
    //alert(response.data.Data)
    $scope.Courses = response.data;
    });
    };
    });

    This way i am printing data by ng-repeater

    Input : 
    

    {{Courses}}

    List of Courses

    *           {{course.Name}}
    

    {{Courses}}

    This is showing data i am getting from action. console.log() also showing data. please suggest me which area i need to fix in my code as a result ng-repater should work. Thanks

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups