javascript - AngularsJS $http getting data, but not showing up. -


new angularjs , stuck $http getting data asynchronously, not binding / showing data.

the console.log showing data coming through alright. however, since data coming in asynchronously, data coming in after page has loaded.

<!doctype html>  <html>  <head>    <title>iterate on data webservice.</title>  <script  	src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>    <!-- angularjs magic. -->  <script>  	var app = angular.module('myapp', []);  	app.controller('mycontroller', function($scope, $http) {    		/* lets data actual service.  */  		$http.get("http://www.w3schools.com/angular/customers.php").then(  				function(response) {  					console.log("this came -"  							+ response.data.records);  					$scope.names = response.data.records;  				});  	});  </script>      </head>  <body>    	<h1>get data webservice , show on page.</h1>    	<div ng-app="myapp" ng-controller="mycontroller">    		<ul>  			<li ng-repat="x in names">name[{{x.name}}]</li>  		</ul>  	</div>    </body>  </html>

change ng-repat ng-repeat

var app = angular.module('myapp', []);  	app.controller('mycontroller', function($scope, $http) {    		/* lets data actual service.  */  		$http.get("http://www.w3schools.com/angular/customers.php").then(  				function(response) {  					console.log("this came -"  							+ response.data.records);  					$scope.names = response.data.records;  				});                $scope.test = "tes1t";          	});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>  <body>    	<h1>get data webservice , show on page.</h1>    	<div ng-app="myapp" ng-controller="mycontroller">    		<ul>  			<li ng-repeat="x in names">name[{{x.name}}]</li> <!-here ng-repeat ->  		</ul>  	</div>    </body>


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -