mardi 28 juin 2016

Changes made to $scope in directive's controller unavailable to the view

I have the following code:

<div my-dir bar="test">
  {{foo}}
</div>

And the following directive:

    restrict: 'A',
    scope:
    {
        bar: '@'      
    },
    link: link,
    controller: controller

In the controller I'm doing this:

function controller($scope)
{
    console.log("in ctrl", $scope);
    $scope.foo = 'test'
}

However $scope.foo isn't accessible to the view code. It doesn't reflect the update.

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire