JSFiddle - React, Tailwind, and code Playground

by Michael Bazos

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.js"></script>
<div ng-app="myApp" ng-controller="DemoCtrl">
    <div dy-directive index="index"></div>
</div>

JavaScript

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

app.directive('dyDirective', function () {
    return {
        restrict: 'A',
        scope: {
            index: '='

        },
        link: function (scope, elem, attr) {
            console.log(scope.index);
            scope.$watch('index', function () {
                console.log(scope.index);
            });
        }
    }
});

app.controller('DemoCtrl', function ($scope) {
    $scope.index = 0;
});