I need to auto-update in my application when background changes change. I added a button to reload the GET for my back-end, but I do not want to do this. This is my code.
<body data-ng-app="myPr"> <div ng-controller="TodosController"> <div ng-repeat="todo in todos"> <p>{{todo.title}} ...... {{todo.is_completed}}</p> </div> <button ng-click="reload()">Reload</button> </div> </body>
my app.js
var myPr = angular.module('myPr',[]); myPr.controller("TodosController", function ($scope,$http){ $scope.reload = function () { $http.get('http://localhost:3000/api/todos'). success(function (data) { $scope.todos = data.todos; }); }; $scope.reload(); });
thanks
source share