Angular: Empty Fiddle

http://angularjs.org/

by Sergey Guns

HTML

<script src="https://code.angularjs.org/1.3.9/angular.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
    <div>selected item is {{selected}}</div>
    <div ng-repeat='item in collection'>
        <button ng-click='func(item)'>{{item}}</button>
    </div>
</div>

JavaScript

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

myApp.controller('MyCtrl', function($scope) {
    $scope.collection = [1, 2, 3, 4, 5]
    $scope.selected = $scope.collection[0]
    $scope.func = (item)=> $scope.selected = item
})