-1

I want to build a common class for the frequently used statements in function.

and i am getting error if i use this keyword within a function.

 import {Component}  from '@angular/core';
    import { DomSanitizer } from '@angular/platform-browser';
    export class CommonFunctions  {
        
        constructor(private  sanitizer: DomSanitizer){
    
        }
        static sum(a: number, b: number): number {
            return a + b;
        }
     
        static formatImage(projectList:any):any  {
            
          
            for (var index in projectList) {
                let images = projectList[index].img;
                let objectURL = 'data:image/jpeg;base64,' + images;
//error in this line
                let thumbnail1 = this.bypassSecurityTrustUrl(objectURL);
               projectList[index].img = thumbnail1;
        
              }
              return projectList;
            
          }




}
1
  • probably should be this.sanitizer.bypassSecurityTrustUrl(objectURL) Commented Dec 31, 2020 at 7:33

1 Answer 1

1

It should be :

this.sanitizer.bypassSecurityTrustUrl(...)

Instead of

this.bypassSecurityTrustUrl(...)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.