, , , , .
var myApp = angular.module('myApp', []);
function MyCtrl($scope) {
$scope.index = 0;
}
myApp.directive('parent', function () {
return {
transclude: true,
scope: {
index: '='
},
restrict: 'EA',
template: '<h2>Parent {{ index }}</h2>',
compile: function(tE, tA, transcludeFn) {
return function (scope, elem, attrs) {
elem.append(transcludeFn(scope)[1]);
};
}
}
});
myApp.directive('child', function () {
return {
restrict: 'EA',
scope: false,
template: '<p>Child of parent {{ index }}</p>'
}
});
.
, , ngTranscludeDirective , . , , , .
, (, , ).
, , .
. , .
, 5:
link: function(scope) {
scope.index = 5;
}
scope.items , . ( MyCtrl). MyCtrl.
:
link: function(scope) {
scope.somethingElse = foo;
}
scope.somethingElse , .