I am trying to use the $interval service in AngularJS to flash a text back and forth in color (red to black).  The following code is not working and I don't know why.
This is the HTML (this question is for the span section).
<div class="jumbo" ng-mouseenter="myStyle = {'background-color':'gold'}" ng-mouseleave="myStyle ={'background-color':''}">
        <h1 ng-style="myStyle">Sanjay Kumar Technology Services <span class="iflash" ng-style ="{{textColor}}">(NodeJS & AngularJS Demo)</span></h1>
</div>
This is the AngularJS in the .js file:
(function () {
    var app = angular.module("SanjayPage", []);
    var MainController = function ($scope, $http, $interval) {
        $scope.textColor = "{'color': 'black'}";
        var change = 1;
        var flash = function () {
            if (change === 1) {
                $scope.textColor = "{'color': 'red'}";
                change = 2;
            } 
            else {
                $scope.textColor = "{'color': 'black'}";
                change = 1;
            }
        };
        var colorFlash = function () {
            $interval(flash, 1000);
        };
        colorFlash();
    };
   app.controller("MainController", ["$scope", "$http", "$interval", MainController]);
}());
If I change $interval(flash, 1000); to $interval(flash(), 1000); then I can get it to run once and change the color black to red.  But the interval does not repeat. What am I missing?




