mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-04-03 15:00:34 +00:00
fix($compile): always instantiate controllers in parent->child order
This reverts commit 683fd713c4.
It turns out that there is some existing code that relies on the
incorrect timing. Rather than breaking these apps that depend on
stable releases, we are going to keep this changeo only in master
and the apps will need to migrate to the correc timing during the
1.2 upgrade.
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* @ngdoc directive
|
|
* @name ng.directive:ngTransclude
|
|
*
|
|
* @description
|
|
* Insert the transcluded DOM here.
|
|
*
|
|
* @element ANY
|
|
*
|
|
* @example
|
|
<doc:example module="transclude">
|
|
<doc:source>
|
|
<script>
|
|
function Ctrl($scope) {
|
|
$scope.title = 'Lorem Ipsum';
|
|
$scope.text = 'Neque porro quisquam est qui dolorem ipsum quia dolor...';
|
|
}
|
|
|
|
angular.module('transclude', [])
|
|
.directive('pane', function(){
|
|
return {
|
|
restrict: 'E',
|
|
transclude: true,
|
|
scope: { title:'@' },
|
|
template: '<div style="border: 1px solid black;">' +
|
|
'<div style="background-color: gray">{{title}}</div>' +
|
|
'<div ng-transclude></div>' +
|
|
'</div>'
|
|
};
|
|
});
|
|
</script>
|
|
<div ng-controller="Ctrl">
|
|
<input ng-model="title"><br>
|
|
<textarea ng-model="text"></textarea> <br/>
|
|
<pane title="{{title}}">{{text}}</pane>
|
|
</div>
|
|
</doc:source>
|
|
<doc:scenario>
|
|
it('should have transcluded', function() {
|
|
input('title').enter('TITLE');
|
|
input('text').enter('TEXT');
|
|
expect(binding('title')).toEqual('TITLE');
|
|
expect(binding('text')).toEqual('TEXT');
|
|
});
|
|
</doc:scenario>
|
|
</doc:example>
|
|
*
|
|
*/
|
|
var ngTranscludeDirective = ngDirective({
|
|
controller: ['$transclude', '$element', function($transclude, $element) {
|
|
$transclude(function(clone) {
|
|
$element.append(clone);
|
|
});
|
|
}]
|
|
});
|