Directives in Angular 1.X default to two-way binding. By default, components have isolated areas. I have a view that looks like this:
<div class="my-view">
{{controllerVariable}}
</div>
If I have the above setting as a directive, it controllerVariableloads correctly in the following situation:
<div ng-controller="myController">
<my-view></my-view>
</div>
But if I configured it as a component using the following:
myApp.component('myView', {
templateUrl: '/path/to/view',
bindings: '='
});
then the value of the variable is not displayed. I tried adding $ctrlto the variable:
<div class="my-view">
{{$ctrl.controllerVariable}}
</div>
but it also does not display the value.
What am I missing here?
source
share