I am using http request to get data from json file which I than use in controller.

```
    app.controller('mainCtrl', ['$scope', 'loaderService', function ($scope, loaderService) {
   //gets data from service 
        loaderService.getLoadedHtml().then(function (result) {
            $scope.fields = result.data;
        });
    }]);

```

I need to update directive when this `$scope.fields` change as

```
app.directive('dform', function () {
    return {
        scope: {
            action: '@',
            method: '@',
            html: '='
        },
        link: function (scope, elm, attrs) {
            var config = {
                "html": scope.fields
            };

            scope.$watch('fields', function (val) {
                elm.dform(config);
            });

            //console.log(config);
            //elm.dform(config);
        }
    };
})

```

and here is how I am using this directive

```
<div html="fields" dform></div>

```

But in my case when $scope.fields changes, i get `scope` as undefined in my directive $watch function.

**Question:**

How can I get the updated value for scope.fields in scope.$watch function?