Using function for evaluating conditions
While binding a widget to an expression using Use Expression option, in case expressions becoming complex, it is advisable to write an evaluation function for clarity and reusability. We will show how it can be done with the help of an example.
Use Case
Show/Hide an image (say, tick image) in a page based on the condition. You can enter the expression directly or write a function.
Steps
Open the binding dialog for the tick picture > show property
Select “Use expression” tab. Type function “isShowTick(item)” where “item” is passed as argument.
Click on the script tab.
Add following script
//function to show the tick $scope.isShowTick = function(item) { return item.actioncount > 0 ? true:(item.note_text ? (item.note_text !== '' ? true : false) : false); }
Run the application to test