2017-05-26 7 views
-1

Ich benutze Knoten js und eckigen js und Lenker als View-Engine. Ich versuche grundlegende Anwendungen/Beispiele, aber keine Daten auf der Browser-Seite. Daten zeigt im Browser ist leer.Browser zeigt keine Daten oder Fehler

Ich habe console.log im Browser, ich habe Daten als [Objekt] [Objekt].

Included angular: 
<script 
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> 
</script> 

On handlebars page : [enter image description here][1]table: 

<table ng-controller="myCtrl" border="1"> 
    <li ng-if="records.length === 0">(No items in this list yet!)</li> 

    <tr ng-repeat="x in records"> 
     <td>{{x.Name}}</td> 
     <td>{{x.Country}}</td> 
    </tr> 
    </table> 

<script> 
var app = angular.module('tennisApp',[]); 
app.controller('myCtrl', function($scope, $http) { 
    $scope.data = []; 
    var request = $http.get('http://localhost:3030/aitaAngular');  
    request.success(function(response) {    
     $scope.data = response; 
     console.log(response); 
     console.log($scope.data); 
    }); 
    request.error(function(response){ 
     console.log('Error: ' + response); 
    }); 
}); 
</script> 
+0

Der Name Ihres Controllers ist anders. Verwenden Sie den gleichen Controller-Namen. Wo ist deine deine ng-App? –

+0

Sie setzen Daten auf '$ scope.data', aber in' ng-repeat' ist es 'records'. – Pengyy

+0

@Dinesh Ich definierte ng-app in Körper –

Antwort

0

Sie haben falsche Controller-Namen gibt. Sie verwenden myCrtl im Blick und Userdetails in Javascript Es gibt keinen ng-App auch

  <!DOCTYPE html> 
      <html> 
      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> 
      <body> 
      <div ng-app="myApp"> 
      <table ng-controller="userDetails" border="1"> 
       <li ng-if="records.length === 0">(No items in this list yet!)</li> 
       <tr ng-repeat="x in records"> 
        <td>{{x.Name}}</td> 
        <td>{{x.Country}}</td> 
       </tr> 
       </table>      
      </div> 
      <script> 
      var app = angular.module('myApp', []); 
      app.controller('userDetails', function($scope, $http) { 
       $scope.data = []; 
       var request = $http.get('http://localhost:3030/aitaAngular');  
       request.success(function(response) {    
        $scope.data = response; 
        console.log(response); 
        console.log($scope.data); 
       }); 
       request.error(function(response){ 
        console.log('Error: ' + response); 
       }); 
      }); 
      </script> 
      </body> 
      </html> 
0

ich noch hier aktualisiert, die gleiche Problem

<body ng-app="tennisApp"> 

<table ng-controller="myCtrl" border="1"> 
    <li ng-if="records.length === 0">(No items in this list yet!)</li> 

    <tr ng-repeat="x in records"> 
     <td>{{x.Name}}</td> 
     <td>{{x.Country}}</td> 
    </tr> 
</table> 

<script> 
var app = angular.module('tennisApp',[]); 
app.controller('myCtrl', function($scope) { 
$scope.records = [ 
{ 
    "Name" : "Alfreds Futterkiste", 
    "Country" : "Germany" 
}, 
{ 
    "Name" : "Berglunds snabbköp", 
    "Country" : "Sweden" 
}, 
{ 
    "Name" : "Centro comercial Moctezuma", 
    "Country" : "Mexico" 
}, 
{ 
    "Name" : "Ernst Handel", 
    "Country" : "Austria" 
} 
] 
console.log($scope.records); 
}); 
</script> 

Console on browser