admin管理员组文章数量:1416328
I'm trying to assign height to a img using ngStyle and for that I'm calculating 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 do run it it gives 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)
I'm trying to assign height to a img using ngStyle and for that I'm calculating 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 do run it it gives 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)
Share
Improve this question
asked Oct 5, 2016 at 6:14
Akhilesh KumarAkhilesh Kumar
9,36513 gold badges61 silver badges97 bronze badges
1 Answer
Reset to default 10Per documentation:
Perhaps more surprising, template expressions cannot refer to anything in the global namespace. They can’t refer to window or document. They can’t call console.log or Math.max. They are restricted to referencing members of the expression context.
https://angular.io/docs/ts/latest/guide/template-syntax.html
You can work around it like:
class Component {
myParseInt = parseInt;
}
html
[ngStyle]="{'height':(myParseInt (...
本文标签: javascriptTypeError selfparentparentcontextparseInt is not a functionStack Overflow
版权声明:本文标题:javascript - TypeError: self.parent.parent.context.parseInt is not a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745248904a2649700.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论