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

feat(compiler): pass $element to controller instantiation #9516

Merged
merged 1 commit into from
Sep 9, 2016

Conversation

devversion
Copy link
Member

  • Pass the $element local to the instantiated controller, as same as a normal Angular 1.x DDO.

Closes #9507.

* Pass the `$element` local to the instantiated controller, as same as a normal Angular 1.x DDO.

Closes angular#9507.
@devversion devversion added the needs: review This PR is waiting on review from the team label Sep 4, 2016
var invokeCtrl = $controller(controller, locals, true, controllerAs);

var ctrlLocals = angular.extend(locals, {
$element: element
Copy link
Contributor

Choose a reason for hiding this comment

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

What about the $attr?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's unfortunately not possible, because the Attributes constructor is internal-only.

https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L1508

Also doesn't make any sense to have the $attrs here, because the template is always static, and the user can't specify attributes dynamically.

Copy link
Member

Choose a reason for hiding this comment

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

$attrs might make sense once we start supporting content elements.

Copy link
Member Author

@devversion devversion Sep 4, 2016

Choose a reason for hiding this comment

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

It's still not possible. Though contentElement's are still not dynamic, those are just to avoid compilation each time and are pre-rendered elements.

Once I created this functionality, the intention was just to support pre-rendered DOM elements.

@devversion
Copy link
Member Author

@ThomasBurleson @crisbeto Any other feedback to address ?

@crisbeto
Copy link
Member

crisbeto commented Sep 5, 2016

Nope, it LGTM.

@ThomasBurleson ThomasBurleson added needs: presubmit and removed needs: review This PR is waiting on review from the team labels Sep 5, 2016
@ThomasBurleson ThomasBurleson added this to the 1.1.2 milestone Sep 5, 2016
@kara kara added pr: merge ready This PR is ready for a caretaker to review and removed needs: presubmit labels Sep 9, 2016
@kara kara merged commit be038d1 into angular:master Sep 9, 2016
@devversion devversion deleted the feat/dialog-pass-element branch September 10, 2016 14:44
Frank3K pushed a commit to Frank3K/material that referenced this pull request Sep 11, 2016
* Pass the `$element` local to the instantiated controller, as same as a normal Angular 1.x DDO.

Closes angular#9507.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr: merge ready This PR is ready for a caretaker to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants