Angularjs : Remove old list item values from DOM

I am using ng-repeat to populate list items and further animate them using vTicker. My app.js makes a call to php which returns an object, which is then read by ng-repeat. The issue is, even after the object returns a new message, old message is still visible in html. However, if the page is refreshed, the old values gets cleared and only the latest message is displayed. How can I achieve this without having the page refreshed.

App.js :

   $scope.refreshbc = function ()     {         $scope.bclist = "";         $http.get(bcurl).then(function(bcresponse)          {             if(bcresponse.data.indexOf("Entry does not exist in                 database") > -1)             {                $scope.bclist = "";                console.log($scope.bclist);             } else              {               $scope.bclist = bcresponse.data;                if($scope.bclist[0].msg == "No alerts.")               {                 $scope.mibtn = "btn-success";                 $scope.mitxtcol = "black";                } else                {                  $scope.mibtn = "btn-danger";                 $scope.mitxtcol = "white";               }            }      }); 

$scope.refreshbc(); $interval( function(){ $scope.refreshbc(); }, 30000);

html:

  <div id="example"  style="margin-top:39px;color:#cccc00;font-                                                     size:15px;">     <ul  id="tickerul" style="list-style: none;">       <li ng-init="stvticker()" ng-if="bclist[0].msg !== null" ng-       repeat="bc in bclist track by $index" >{{bc.msg}}</li>       <li style=""></li>     </ul>   </div> 

Replay

Category: angularjs Time: 2016-07-31 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.217 (s). 12 q(s)