When i try to compare the string with ng-if from angularjs, i m getting the errors in console.
Below are my data:
value for {{reports[0]}}
is:
{"name":null,"discount":0,"margin":0,"reportType":"REPORT_TOP_SELLERS","revenue":0,"variantKey":null,"rank":1,"productKey":"10692-1_en_US","purchasedUnits":0,"abandonedUnits":0}
value for {{reports[0].reportType}} is:
REPORT_TOP_SELLERS
Below are the code which throws the Error:
<div ng-if="{{reports[0].reportType}} === 'REPORT_TOP_SELLERS'">
Error:
Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{reports[0].reportType}} === 'REPORT_TOP_SELLERS'] starting at [{reports[0].reportType}} === 'REPORT_TOP_SELLERS'].
Please help.
change html code :
<div ng-if="reports[0].reportType == 'REPORT_TOP_SELLERS'">
Use without the expression, it should be,
if its angular
<div *ngIf="reports[0].reportType === 'REPORT_TOP_SELLERS'">
angularjs
<div ng-if="reports[0].reportType === 'REPORT_TOP_SELLERS'">
do not use brackets just use it direct
<div ng-if="reports[0].reportType === 'REPORT_TOP_SELLERS'">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With