0

I have used below code for total :

<span>  
 {{ ((item.USWIPQtyValue * 1)) + (item.UKWIPQtyValue * 1)}}    </span>

Here I can't convert string to int. So in begining time NaN is displayed in span tag. So how to apply parseInt function at html side.

4
  • What value causes the problem? Commented Jan 9, 2017 at 12:12
  • When I have no value then it is taking Nan in span then what to do? Commented Jan 9, 2017 at 12:14
  • What is I in ` I have no value`? Commented Jan 9, 2017 at 12:15
  • Have you tried the initialization like I suggested? Commented Jan 10, 2017 at 20:57

1 Answer 1

1

Try to initiliaze your item object correctly before initial load. In javascript, undefined * 1 is equal to NaN (Not a Number) and NaN + NaN = NaN (still Not a Number).

So I guess your expression evaluates as (undefined * 1) + (undefined * 1) = NaN + NaN = NaN

Both USWIPQtyValue and UKWIPQtyValue must be set like:

var item = {
    USWIPQtyValue: 0,
    UKWIPQtyValue: 0
};
Sign up to request clarification or add additional context in comments.

Comments

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.