TypeError: self.parent.parent.context.parseInt is not a function

I am trying to assign the height to img using ngStyle, and for this I calculate the height with some Math operation as follows:

<div [ngSwitch]="tbNm?tbNm:'itm0'"> <ion-list *ngFor="let vl of scrnshot;let ind=index"> <img *ngSwitchCase="'itm'+ind" alt="Akhilesh" [ngStyle]="{'height':(parseInt(vl.names[0].hitWid.bdHt+(websitTyp(vl._id.origin)?100:0)))+'px','width':(vl.names[0].hitWid.bdWd+'px')}" [src]="vl.names[0].base64"> </ion-list> </div> 

But when I run it, it gives the following error:

 error_handler.js:51 TypeError: self.parent.parent.context.parseInt is not a function at DebugAppView._View_HomePage9.detectChangesInternal (HomePage.ngfactory.js:1444) at DebugAppView.AppView.detectChanges (view.js:272) at DebugAppView.detectChanges (view.js:377) at DebugAppView.AppView.detectContentChildrenChanges (view.js:290) at DebugAppView._View_HomePage8.detectChangesInternal (HomePage.ngfactory.js:1407) at DebugAppView.AppView.detectChanges (view.js:272) at DebugAppView.detectChanges (view.js:377) at DebugAppView.AppView.detectContentChildrenChanges (view.js:290) at DebugAppView._View_HomePage0.detectChangesInternal (HomePage.ngfactory.js:270) at DebugAppView.AppView.detectChanges (view.js:272) 
+5
source share
1 answer

In the documentation:

Perhaps more surprisingly, template expressions cannot refer to anything in the global namespace. They cannot refer to a window or document. They are cant call console.log or Math.max. They are limited to the reference members of the expression context.

https://angular.io/docs/ts/latest/guide/template-syntax.html

You can get around it like:

 class Component { myParseInt = parseInt; } 

HTML

 [ngStyle]="{'height':(myParseInt (... 
+9
source

Source: https://habr.com/ru/post/1257717/


All Articles