JSFiddle - React, Tailwind, and code Playground

HTML

<div ng-app="myApp">
    <ol>
        <li>If you press the button before the timeout, the div will be shown, and the value of food.foo will be locked as "pie".  When the timeout fires a few seconds later, the value will remain unchanged.</li>
        <li>BUT if you wait for 6 seconds and allow it to timeout before clicking the button, the timeout will indeed change the value of food.foo to be "cake".</li>
        <li> click "run" to retry.</li>
    </ol>
    <my-directive></my-directive>
</div>

JavaScript

myApp = angular.module("myApp", []);

myApp.directive("myDirective", function() {
    var d = {};
    d.restrict = "E";
    d.template = '<div ng-show="food.show">hi, I like <input type="text" ng-model="food.foo"> and, in case you forgot, that\'s {{food.foo}}</div><button ng-click="food.show = true">show me</button>';
    d.link = function(scope, element, attrs) {
        scope.food = {};
        scope.food.foo = "pie";
        scope.food.show = false;
        setTimeout(function() {
            alert("timeout: setting scope.food.foo = 'cake'");
            scope.food.foo = "cake";
        }, 6000);
    };
    return d;
});