I am familiarizing myself with angular.js and it seems pretty easy returning Json Data from a file by using $Http.Get.
In an example I would have get my json data like this
var artistControllers = angular.module('artistControllers', []);
artistControllers.controller('ListController', function ($scope, $http) {
$http.get('json/jsonAngular.txt').success(function (data) {
$scope.artists = data;
});
});
How would I get a JsonResult and assign this to my $scope.artists for example.
[HttpPost]
public JsonResult GetArtists()
{
ViewModel model = new ViewModel();
model.GetArtists();
return Json(new
{
Artists = model.Artists
});
}
where my class would look like this as an example
public class Artist
{
public string Initial { get; set; }
public string Surname { get; set; }
}
Is there perhaps a working example of where I could return a JsonResult and render it in my html.