HTML-код:
<div ng-controller="MyController">
<div>{{ hello }}</div>
<div my-terminal>{{hello}}</div>
</div>
JS код:
const app = angular.module('app', [])
app.controller('MyController', function ($scope) {
$scope.hello = 'Hello, AngularJS'
})
app.directive('myTerminal', function () {
return {
restrict: 'A',
terminal: true,
link: function () {
console.log('--- myTerminal')
}
}
})
Обратите внимание, что terminal
равно true
.
Результат:

Из документа angularjs, который я обнаружил, когда terminal
равен true
, любые другие директивы, примененные к тому же элементу с более низким приоритетом, не будут выполняться, но я не могу объяснить, почему <div my-terminal>{{hello}}</div>
не будет отображать выражение {{hello}}
Небольшая полная демонстрация по этому вопросу: https://github.com/freewind-demos/angularjs1-directive-terminal-issue-demo