ng2-ui / auto-complete

Angular Auto Complete component and directive
https://ng2-ui.github.io/dist/#/auto-complete
MIT License
279 stars 122 forks source link

Http required when using a remote url as source #361

Closed estouaway closed 5 years ago

estouaway commented 5 years ago

I've been using this component for quite a while, but after migration to angular 6 I'm having this error, saying that Http is required.

After looking at the sources I realised that http as HttpClient is not being injected as supposed and it stays null.

I have no ideia if this is an issue with the migration to 6, anyone have any idea? or some pointers?

Oh and I've been using it as a directive. Like ths:

<input ngui-auto-complete [source]="appConfigs.endpoint" />

And this is where everything fails, I'm guessing:

auto-complete.ts

import { HttpClient, } from '@angular/common/http';

/**
 * provides auto-complete related utility functions
 */
@Injectable()
export class NguiAutoComplete {

    constructor(@Optional() private http: HttpClient) {
        // ...
    }

deleted some code for clarity.

thanks

almothafar commented 5 years ago

Well, I think it is indeed required if you want to request a URL, I'm not sure what the problem? If your client is null, it may be another issue in the project itself? May you try just to inject Http in your app.component as for example (or the bootstrapped component) and see if the issue is still there?