8000 `$onInit` and friends by petebacondarwin · Pull Request #13763 · angular/angular.js · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$onInit and friends #13763

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
50b0c1a
feat($compile): call `$ngOnInit` on directive controllers after contr…
petebacondarwin Jan 13, 2016
cf4e7be
test($compile): check that $onInit is called correctly for ES6 classes
petebacondarwin Jan 13, 2016
452dd39
docs($compile): document the new `$onInit` controller hook
petebacondarwin Jan 13, 2016
f72ecbd
feat($compile): allow `require` to be an object
petebacondarwin Jan 13, 2016
b2c0b05
feat($compile): allow required controllers to be bound to the directi…
petebacondarwin Jan 13, 2016
37793ce
feat($compile): allow `require` to be an object
petebacondarwin Jan 14, 2016
a12ddc6
test($compile): check explicit return controllers are not broken by b…
petebacondarwin Jan 14, 2016
59feecc
feat($compile): allow required controllers to be bound to the directi…
petebacondarwin Jan 14, 2016
8040bab
feat($compile): call `$ngOnInit` on directive controllers after contr…
petebacondarwin Jan 14, 2016
9e6db1a
feat($compile): allow required controllers to be bound to the directi…
petebacondarwin Jan 14, 2016
1d18df2
fix($compile): ensure controllers with return value constructors are …
petebacondarwin Jan 15, 2016
4b304a6
docs($compile): squash me
petebacondarwin Jan 15, 2016
cae40ca
fix($compile): only bind required controllers if `bindToController` i…
petebacondarwin Jan 15, 2016
276b9ee
docs($compile): fix typo
petebacondarwin Jan 15, 2016
6d66a75
fix($compile): only bind required controllers if `bindToController` i…
petebacondarwin Jan 15, 2016
32b7da3
test($compile): check that $onInit is called correctly for ES6 classes
petebacondarwin Jan 15, 2016
cb495a5
fix($compile): only bind required controllers if `bindToController` i…
petebacondarwin Jan 15, 2016
270e230
fix($compile): ensure controllers with return value constructors are …
petebacondarwin Jan 15, 2016
281d987
fix($compile): only bind required controllers if `bindToController` i…
petebacondarwin Jan 15, 2016
9f76a11
test($compile): check that $onInit is called correctly for ES6 classes
petebacondarwin Jan 15, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test($compile): check explicit return controllers are not broken by b…
…inding require
  • Loading branch information
petebacondarwin committed Jan 14, 2016
commit a12ddc64091a9c94d3cefb4efd156ed930fe6b75
49 changes: 49 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5381,6 +5381,55 @@ describe('$compile', function() {
});
});

it('should bind required controllers to controller that has an explicit constructor return value', function() {
var parentController, siblingController, meController;

function ParentController() { this.name = 'Parent'; }
function SiblingController() { this.name = 'Sibling'; }
function MeController() {
meController = {
name: 'Me',
$onInit: function() {
parentController = this.container;
siblingController = this.friend;
}
};
spyOn(meController, '$onInit').andCallThrough();
return meController;
}

angular.module('my', [])
.directive('me', function() {
return {
restrict: 'E',
scope: {},
require: { container: '^parent', friend: 'sibling' },
controller: MeController
};
})
.directive('parent', function() {
return {
restrict: 'E',
scope: {},
controller: ParentController
};
})
.directive('sibling', function() {
return {
controller: SiblingController
};
});

module('my');
inject(function($compile, $rootScope, meDirective) {
element = $compile('<parent><me sibling></me></parent>')($rootScope);
expect(meController.$onInit).toHaveBeenCalled();
expect(parentController).toEqual(jasmine.any(ParentController));
expect(siblingController).toEqual(jasmine.any(SiblingController));
});
});


it('should require controller of an isolate directive from a non-isolate directive on the ' +
'same element', function() {
var IsolateController = function() {};
Expand Down
0