- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 03:38 AM
Hi All,
<td ng-if="item.response_code == '300'"> <button id="btnIncident" name="submit" ng-click="c.remove(item.name)" type="submit">Remove</button></td>
</tr>
The above line is not working as expected, Remove button is not visible all time, irrespective of response code.And it is visible and working as expected if i remove 'ng-if="item.response_code == '300'"'.
How to compare the item.response_code value?
Thanks & Regards,
Swathi.
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 07:19 AM
I forget sometimes how javascript works. This should do the trick:
item.response_code === '300'
Depending upon the situation javascript interprets '300' and 300 as being equal or the same. Whereas if you use the equality where it checks the type as well then it will prove to be actually an integer vs a string version of 300.
But to answer your other question how to compare without ng-if:
Simply place the expression in the markup:
<div> {{ item.response_code === '300' }} </div>
That syntax is what is doing the comparison. ngIf is just looking for a result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 03:49 AM
Hi Swathi,
You could print out the value of item.response_code within the rendered view:
<td> {{item.response_code }}<button id="btnIncident" name="submit" ng-click="c.remove(item.name)" type="submit">Remove</button></td>
</tr>
or print out the comparison to ensue the output is what you're expecting:
<td> {{ item.response_code == '300' }} <button id ...
But just for clarity if ng-if's comparison is true it will display the markup. If it's false it won't display.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 04:40 AM
Hi Chris,
Printed value is giving 300
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 05:24 AM
What about the comparison? Did you print out the comparison result in the html:{{ item.response_code == '300' }}?
What was the result? If the value of item.response_code showed '300' and the result of the comparison is false then you might want to also check the typeof of the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2018 05:40 AM
Hi Chris,
It shows 300==300. How to compare without ng-if?