2016-10-19 2 views
0

Ich habe ein Problem mit diesem Code Ich habe Json Daten von meinem asp.net Web API. Ich konnte diese Daten nicht von angularjs erhalten. wie Sie den Code sehen können;Angularjs http erhalten von JSON

<!DOCTYPE html> 
<html ng-app="myapp"> 
<head> 
    <title ng-bind="helloAngular"></title>  
    <script src="~/Scripts/angular.min.js"></script> 
     <script> 
       var myapp = angular.module('myapp', []); 
       myapp.controller('myController', function ($scope, $htpp){ 
        $htpp.get({ 
         method:'GET', 
         url:'http://localhost:50972/api/product'}) 
         .success(function (response) { 
         $scope.result = response.statusText 
        }); 
       }); 
     </script> 
    </head> 
    <body ng-controller="myController"> 
     <table border="1"> 
       <tr ng-repeat="product in response"> 
        <td>{{product.id}}</td> 
        <td>{{product.name}}</td> 
        <td>{{product.type}}</td> 
       </tr> 
      </table> 
    </body> 
    </html> 
+0

welche Fehler oder Daten werden Sie als Antwort bekommen? Wo ist Ihr Web-API-Code, um zu sehen, was Sie zurückgeben? – Emil

Antwort

0

Sie haben einige Tippfehler: Statt $htpp Verwendung $http

myapp.controller('myController', function ($scope, $http){ 
        $http.get({ 
         method:'GET', 
         url:'http://localhost:50972/api/product'}) 
         .success(function (response) { 
         $scope.result = response.data; 
        }); 
       }); 
Verwandte Themen