JSFiddle - React, Tailwind, and code Playground
by evoSL
HTML
<ul ng-controller="DaCtrl as d">
<li ng-repeat="item in d.itemlist">{{item.id}}</li>
</ul>
<button onclick="addItems()">Click me</button>
JavaScript
var app = angular.module('jobs', []);
app.controller('DaCtrl',function(){
this.itemlist = listObj;
});
var listObj = [{id:"001"},{id:"002"},{id:"003"}];
function addItems(){
listObj = [];
dataObj = ajax();
//I need to remove all the existing elements and add new set of items to the array just like this.
listObj = dataObj;
}
var i = 0;
function ajax(){
//Data will come from ajax request
i++;
return [{id:"005"+i},{id:"006"+i},{id:"007"+i}];
}