user11352561
user11352561

Reputation: 2647

Angular Typescript Error - charset is deprecated. (deprecation)

I am using Angular 7. I have loadscript.directive.ts

import { Directive, Input } from '@angular/core';

@Directive({
  selector: '[appLoadscript]'
})

export class LoadscriptDirective {

  @Input('appLoadscript') script: any;

  constructor() {  }

  ngOnInit() {
    let node = document.createElement('script');
    node.src = this.script;
    node.type = 'text/javascript';
    node.async = false;
    node.charset = 'utf-8';
    document.getElementsByTagName('head')[0].appendChild(node);
  }

}

But I got this error:

charset is deprecated. (deprecation)

error

How do I resolve this error in my Angular 7?

Upvotes: 2

Views: 2990

Answers (1)

Jason Goemaat
Jason Goemaat

Reputation: 29234

Don't set the charset: docs

If present, its value must be an ASCII case-insensitive match for "utf-8". Both it’s unnecessary to specify the charset attribute, because documents must use UTF-8, and the script element inherits its character encoding from the document.

Upvotes: 2

Related Questions