angularjs - I am trying to use $resource for fetching data from ASP.NET webApi but it is not working -


you can see errors in image

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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -