-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: Expose $inject helper #115
Comments
This would mainly expose a way to set |
you can do something like: // In my.component.ts
@Component({ selector: 'my-component' })
class MyComponent {
constructor(depService: MyDependency) {
// ...
}
}
// In my.component.spec.ts
import {provide} from 'ng-metadata/core';
angular.mock.inject(($controller) => {
const [compName,annotatedComponent] = provide(MyComponent);
let component = $controller(annotatedComponent); // Needs $inject annotated
} although I highly recommend to not use this old Angular 1 apis. if you already have a component via ngMetadata const depService = new MyDependency();
const component = new MyComponent(depService); https://hotell.gitbooks.io/ng-metadata/content/docs/api/testing/function.html |
will this work for you @aciccarello ? |
Sorry for not replying earlier. I tried using the provide function earlier but had some problems. I'll try that again (hopefully tomorrow) and see if I can make it work. As a workaround for now I've been manually initializing the component class. |
The I haven't looked at it too much but I think the TestComponentBuilder is how the component would be initialized in ng2. It probably should be a goal for #93. It's marked as stable but who knows 😒 Note: I'm currently using ng-metadata 1.12 |
It would be helpful if there was a public function which could set the $inject property on a function. This would allow using type annotations when interacting with classic Angular 1 apis.
The text was updated successfully, but these errors were encountered: