ngx-embed-video icon indicating copy to clipboard operation
ngx-embed-video copied to clipboard

Error on Angular 6.0.3

Open eluizbr opened this issue 6 years ago • 8 comments

Hi,

I have an issue on Angular 6.0.3

ERROR in Error during template compile of 'AppModule'
  Function calls are not supported in decorators but 'EmbedVideo' was called.

There support to this version ?

Thanks!

eluizbr avatar Jan 29 '19 13:01 eluizbr

We are facing same issue, any updates on it?

bhaumikdarji avatar Feb 15 '19 06:02 bhaumikdarji

I'm also facing same issue. Is there any update ?

pavansai1122 avatar Feb 15 '19 11:02 pavansai1122

I also had the same issue. The issue was that the official documentation says to import as :

import { HttpClientModule } from '@angular/common/http'; import { EmbedVideo } from 'ngx-embed-video';

@NgModule({ imports: [HttpClientModule, EmbedVideo.forRoot()] }) export class AppModule {}

the solution is to import EmbedVideoService and not EmbedVideo as

import { EmbedVideoService } from 'ngx-embed-video';

@NgModule({ imports: [], providers:[EmbedVideoService] }) export class AppModule {}

I hope its helpful

lazymesh avatar Feb 18 '19 03:02 lazymesh

Hi

I found another way to fix this issue. I created a provider:

import { HttpClient } from '@angular/common/http';
import { EmbedVideoService } from 'ngx-embed-video/dist';
import { EmbedVideoServiceFactory } from './embed-video-service.factory';
import { DomSanitizer } from '@angular/platform-browser';

export const EmbedVideoServiceProvider = {
  provide: EmbedVideoService,
  useFactory: EmbedVideoServiceFactory,
  deps: [ HttpClient, DomSanitizer ]
};

also, the factory used:

import { HttpClient } from '@angular/common/http';
import { DomSanitizer } from '@angular/platform-browser';
import { EmbedVideoService } from 'ngx-embed-video/dist';

export const EmbedVideoServiceFactory = function(http: HttpClient, sanitizer: DomSanitizer ) {
  return new EmbedVideoService(http, sanitizer);
};

then, add it on providers array:

@NgModule({
  providers: [
    EmbedVideoServiceProvider
  ]
})
export class MyModule {
}

cguilhermef avatar Apr 24 '19 20:04 cguilhermef

Thanks cguilhermef for your comment and solution, this helped me solve the final issue running this component in production. For others, cguilhermef's solution solved another error I was receiving once I was able to use AOT compilation. Here is the error I was receiving: ERROR TypeError: Cannot read property 'bypassSecurityTrustHtml' of undefined at n.sanitize_iframe (main.65f0c9c22c382098f35a.js:1) at n.embed_vimeo (main.65f0c9c22c382098f35a.js:1) at n.showSSVideo (main.65f0c9c22c382098f35a.js:1) ... Hope this helps

begolf avatar May 12 '19 19:05 begolf

I also had the same issue. The issue was that the official documentation says to import as :

import { HttpClientModule } from '@angular/common/http'; import { EmbedVideo } from 'ngx-embed-video';

@NgModule({ imports: [HttpClientModule, EmbedVideo.forRoot()] }) export class AppModule {}

the solution is to import EmbedVideoService and not EmbedVideo as

import { EmbedVideoService } from 'ngx-embed-video';

@NgModule({ imports: [], providers:[EmbedVideoService] }) export class AppModule {}

I hope its helpful

I got it working using your solution @lazymesh. Thanks dude.

kunalkakkad avatar Sep 03 '19 13:09 kunalkakkad

Thanks cguilhermef for your comment and solution, this helped me solve the final issue running this component in production. For others, cguilhermef's solution solved another error I was receiving once I was able to use AOT compilation. Here is the error I was receiving: ERROR TypeError: Cannot read property 'bypassSecurityTrustHtml' of undefined at n.sanitize_iframe (main.65f0c9c22c382098f35a.js:1) at n.embed_vimeo (main.65f0c9c22c382098f35a.js:1) at n.showSSVideo (main.65f0c9c22c382098f35a.js:1) ... Hope this helps

Yes exactly it resolved 2 issues mentioned perfectly. Thanks for solution @cguilhermef as it is much more convenient than another one. Also thanks @begolf for highlighting.

kunalkakkad avatar Sep 28 '19 11:09 kunalkakkad

Hello, I am getting this error with Vimeo:

Access to XMLHttpRequest at 'https://vimeo.com/api/v2/video/10549781.json' from origin ( myurl ) has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.

Has anyone else this issue?

Thank you.

pyrextor avatar Jan 31 '20 14:01 pyrextor