2

I know how to convert a string to an integer in the controller

parseInt( $scope.date)

But i have to do this in the view

<span data-ng-show="item.date">{{ item.date | hbdatetime }}</span>

In the view itself i have to convert the date ( which i am getting as a string ) to an integer so that i can filter with hbdatetime .

I am trying something like this

// <data-ng-show="item.date">parseInt{{ item.date | hbdatetime }}</span> 

Please help in angular way

1
  • 1
    Is hbdatetime a custom filter of yours? If so, do any conversions there. Lastly, you should be able to run any valid JS expression within the curly braces, ie: {{ parseInt(item.date) | hbdatetime }} Commented May 8, 2014 at 14:26

1 Answer 1

8

You need to place the function call to parseInt inside the expression:

<span data-ng-show="item.date">{{ parseInt(item.date) | hbdatetime }}</span> 

Angular will pass the value of item.date to the function and then apply the filter to the return value.

You might want to consider writing your own filter that can handle a string as input.

Sign up to request clarification or add additional context in comments.

1 Comment

I have created one more filter and i am doing this in the filter itself ,thanks

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.