Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
151
rated 0 times [  153] [ 2]  / answers: 1 / hits: 16109  / 10 Years ago, thu, may 8, 2014, 12:00:00

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


More From » angularjs

 Answers
18

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.


[#71126] Tuesday, May 6, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parker

Total Points: 259
Total Questions: 109
Total Answers: 97

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;