mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
test($compile): add test for alternative syntax to get controllers from ancestors
Because the regex that tests the `require` value will match more than just `^^?`, it is important to test other common ways to specify a controller requirement to ensure that a breaking change isn't introduced inadvertently. This adds a test for `?^^`. Closes #9389 Closes #9390
This commit is contained in:
committed by
Caitlin Potter
parent
391d8c04da
commit
f7b2d85a2c
@@ -3720,6 +3720,25 @@ describe('$compile', function() {
|
||||
});
|
||||
|
||||
|
||||
it('should get required parent controller when the question mark precedes the ^^', function() {
|
||||
module(function() {
|
||||
directive('nested', function(log) {
|
||||
return {
|
||||
require: '?^^nested',
|
||||
controller: function($scope) {},
|
||||
link: function(scope, element, attrs, controller) {
|
||||
log(!!controller);
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
inject(function(log, $compile, $rootScope) {
|
||||
element = $compile('<div nested><div nested></div></div>')($rootScope);
|
||||
expect(log).toEqual('true; false');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should throw if required parent is not found', function() {
|
||||
module(function() {
|
||||
directive('nested', function() {
|
||||
|
||||
Reference in New Issue
Block a user