为什么这个transcluded
指令重复Name inside directive = Frank
两次?
我以为我理解了嵌入,但这让我很困惑。
<div ng-app="myApp" ng-controller="myController">
<my-directive>Name in outer controller scope = {{name}}<my-directive/>
</div>
var app = angular.module("myApp", []);
app.controller("myController", function ($scope) {
$scope.name = 'George';
});
app.directive("myDirective", function () {
return {
restrict: 'E',
scope: {},
transclude: true,
template: '<div ng-transclude></div>' +
'<span>Name inside directive = {{name}}</span>',
link: function (scope) {
scope.name = 'Frank'
}
};
});