javascript - ng-repeat angular adding two elements to a div as opposed to one when iterating through array -


i using angular make request return live data. wish display data on home page.

the code in controller follows:

$scope.holder = [];    $http.get('url').success(function(data){       $scope.lines = data.lines;        $.each($scope.lines, function(name){         $scope.holder.push(this.friendly_name);         $scope.holder.push(this.status);       });   }); }); 

the $scope.holder array looks after data has been called:

["bakerloo", "good service", "central", "part closure", "circle", "good service", "district", "part closure", "hammersmith & city", "good service"]

my html looks this:

<body ng-controller="tubecontroller">     <div ng-repeat="item in holder track $index">       {{item}}     </div> </body> 

when display on html page each element of array put separate div looks this:

<div>bakerloo</div> <div>good service</div> <div>central</div> <div>part closure</div> 

what want bunch elements 2 each div has 2 elements array included.

i want page this:

<div>bakerloo service</div> <div>central part closure</div> 

etc.

i have tried many different techniques, , read many other answers on stack overflow cannot it. hoping can help. thanks

try this:

$.each($scope.lines, function(name){     $scope.holder.push( this.friendly_name + " " + this.status ); }); 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -