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

$componentController test helper has different DI results. #15038

Closed
ygrene-austin opened this issue Aug 17, 2016 · 1 comment
Closed

$componentController test helper has different DI results. #15038

ygrene-austin opened this issue Aug 17, 2016 · 1 comment

Comments

@ygrene-austin
Copy link

Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.

Do you want to request a feature or report a bug?
I am reporting a bug.

What is the current behavior?
When using a component in angular 1.5.8 I am able to inject $element into the component controller. It works fine running in the browser. But when used in testing the $componentController's DI errors with unknown provider $elementProvider.

What is the expected behavior?
I Expect it to work in test or in the app.

What is the motivation / use case for changing the behavior?
The behavior is inconsistent.

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
1.5.8
Chrome

@Narretz
Copy link
Contributor

Narretz commented Aug 17, 2016

$element, $attrs and $scope are locals that are injected into the controller. Even when using a compiled template, they are not fetched by the di. So when you call your $componentController, simply add them in the "locals" argument: `$componentController('name', {$element: yourjqLiteWrappedElement, $attrs: ...})

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

No branches or pull requests

2 participants