JSFiddle - React, Tailwind, and code Playground

by sdgluck

HTML

<div ng-controller="ctrl">
    <table>
        <tr ng-repeat="fav in favorites">
            <td>{{fav}}</td>
            <td>
                <input type="button" value="Delete!" ng-click="delete($index)"></input>
            </td>
        </tr>
    </table>
</div>

JavaScript

function ctrl ($scope) {
    $scope.favorites = ["a", "b", "c", "d"];

    $scope.delete = function (index) {
        $scope.favorites.splice(index, 1);
    };

    $scope.$watch(function () {
        return $scope.favorites;
    }, function (newVal, oldVal) {
        console.log(newVal);
    });
};