1

I'm using *ngFor(*ngFor="let radio of items) in div element and inside of this div , using an img element.I am trying to set the src like [src]="radio.getIsActiveIcon()" but "46 ERROR TypeError: _v.context.$implicit.getIsActiveIcon is not a function at Object.eval [as updateRenderer] " error happens. My img element and getIsActiveIcon func is;

<img class="is-active-image" [src]="radio.getIsActiveIcon()">

public getIsActiveIcon(): string {
    if (this.isActive === 1) {
        return 'assets/img/ic_active.png';
    }
    return 'assets/img/ic_not_active.png';
}
1

3 Answers 3

1

Finally,I used Pipe and it works.it's more clear.

Sign up to request clarification or add additional context in comments.

Comments

0
<img class="is-active-image" [src]="getIsActiveIcon()">

Not sure what does radio means, but all you have to do is call the function.

1 Comment

I need to access gecIsActiveIcon() from Radio.ts because it depends on the isActive value inside of Radio.
0

Preventing cross-site scripting (XSS) Cross-site scripting (XSS) enables attackers to inject malicious code into web pages. Such code can then, for example, steal user data (in particular, login data) or perform actions to impersonate the user. This is one of the most common attacks on the web.

To block XSS attacks, you must prevent malicious code from entering the DOM (Document Object Model). For example, if attackers can trick you into inserting a tag in the DOM, they can run arbitrary code on your website. The attack isn't limited to tags—many elements and properties in the DOM allow code execution, for example, and . If attacker-controlled data enters the DOM, expect security vulnerabilities.

for more info go here Angular Security

2 Comments

This works <img class="is-active-image" [src]="radio.isActive == 1 ? 'assets/img/ic_active.png' : 'assets/img/ic_not_active.png'">
Using function to return image url in img tag was a bad idea

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.