angularjs - I am trying to use $resource for fetching data from ASP.NET webApi but it is not working -
i new webapi angular , cannot find proper solution this, please me out , if can please suggest me resources learn topic.
productresource.js file:
(function () { "use strict"; angular.module('random') .factory('productresource', function ($resource) { return $resource("http://localhost:60208/"); }); });
t.js file
var app = angular.module("jobsapp", []); app.controller("jobcontroller", function($scope,$http,productresource) { $scope.jobs = productresource.query(); });
index.cshtml file:
<div ng-app="jobsapp"> <div ng-controller="jobcontroller"> <table class="table"> <tr> <th>job id</th> <th>description</th> <th>minimum</th> <th>maximum</th> </tr> <tr ng-repeat="j in jobs"> <td>{{j.job_id}}</td> <td>{{j.job_desc}}</td> <td>{{j.min_lvl}}</td> <td>{{j.max_lvl}}</td> </tr> </table> </div> </div>
you need inject ngresource
module working. like
(function () { "use strict"; angular.module('random',['ngresource']) .factory('productresource', function ($resource) { return $resource("http://localhost:60208/"); }); });
update
your url seems incorrect too. need create webapi controller
class @ backend communicate, should restful /user/jobs
.
further please ensure have added angular-resource.js
in app.
Comments
Post a Comment