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

feat($componentController): provide isolated scope if none is passed #14425

Merged

Conversation

petebacondarwin
Copy link
Contributor

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

feat

What is the current behavior? (You can also link to an open issue here)

one must always provide a scope for the $componentController helper, which is annoying

What is the new behavior (if this is a feature change)?

now an isolated child of rootScope is created and used if no scope is provided

Does this PR introduce a breaking change?

Nope

Please check if the PR fulfills these requirements

Other information:

locals = {};
}
if (!locals.$scope) {
locals.$scope = locals.$scope || $rootScope.$new(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't locals.$scope || redundant here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops yes. Good spot

@petebacondarwin petebacondarwin added this to the 1.5.4 milestone Apr 13, 2016
// check it is isolated
$rootScope.a = 17;
$ctrl.$scope.a = 42;
expect($rootScope.a).toEqual(17);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this work with non-isolate scope as well ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah. I mean to check that $scope.a was undefined too.

@gkalpak
Copy link
Member

gkalpak commented Apr 13, 2016

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants