I couldn't get an output from this code when I ran it my local machine but the weird part is online editors able to give me an output: http://codepen.io/anon/pen/waXGom
*Im using Adobe Brackets editor
Here is my HTML code:
<!DOCTYPE html >
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
<script src= "app.js"></script>
<body ng-app="MyApp">
<div ng-controller="Controller2">
<button ng-click="add()">Add Object</button>
<button ng-click="reset()">Reset</button>
<div remove="remove($index)" ng-repeat="name in names">
{{name}}
</div>
</div>
</body>
</html>
Here is my JS code:
var myApp = angular.module('myApp', []);
myApp.controller('Controller2', function ($scope) {
$scope.names = [];
var data = ['Dean', 'Andy', 'Dan', 'Wizek', 'Pete', 'Pawel', 'Chris', 'Misko'];
$scope.add = function() {
if (data.length)
$scope.names.push(data.pop());
};
$scope.reset = function(index) {
data.push($scope.names.splice(index, 1)[0]);
};
});
Please help me to figure it out...