ionic get

 前台代码 ng-repeat="item in items"
<ion-list>
	<ion-item class="item-avatar" ng-repeat="item in items">
		<img src="{{item.user.picture.thumbnail}} " />
		<h2>{{item.user.name.first}} {{item.user.name.last}}</h2>
		<p>{{item.user.location.city}} {{item.user.password}}</p>
	</ion-item>
</ion-list>
.factory('PersonService', function($http){
	var BASE_URL = "http://api.randomuser.me/";
	var items = [];
	
	return {
		GetFeed: function(){
			return $http.get(BASE_URL+'?results=10').then(function(response){
				items = response.data.results;
				return items;
			});
		},
		GetNewUsers: function(){
			return $http.get(BASE_URL+'?results=10').then(function(response){
				items = response.data.results;
				return items;
			});
		}
	}
})
.controller('MyCtrl', function($scope, $timeout, PersonService) {
	$scope.items = [];

	PersonService.GetFeed().then(function(items){
		$scope.items = items;
	});
});

你可能感兴趣的:(get,ionic)