Angular: Empty Fiddle

http://angularjs.org/

by Sourabh_

HTML

<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
    <li ng-repeat="item in items">
        {{item.name}}
    </li>
    <button ng-click="change()">Change</button>
</div>

JavaScript

var myApp = angular.module('myApp',[]);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

function MyCtrl($scope) {
    $scope.items = [{name : "abc"},{name : "xyz"},{name : "cde"}];
   
    $scope.change = function(){
        test(function(testItem){
          $scope.items = testItem;
          //$scope.$apply();
        })
    }
    function test(callback){
        var testItem = [
                        {name : "mno"},
                        {name : "pqr"},
                        {name :   "ste"}
                       ];
        setTimeout(function(){callback(testItem)},2000);
    }
}