Is there any way to say in angular something like this :
<th ng-repeat=" o in Odds" >{{o.Name || "-"}}</th>
So if there is no data in o.Name to display "-" ?
Sometimes you need to check if a cell is blank, generally because you might not want a formula to display a result without input. In this case we're using IF with the ISBLANK function: =IF(ISBLANK(D2),"Blank","Not Blank")
Under Display options for this worksheet, select a worksheet, and then do one of the following: To display zero (0) values in cells, select the Show a zero in cells that have zero value check box. To display zero values as blank cells, clear the Show a zero in cells that have zero value check box.
To display errors as blank cells, delete any characters in the box. Change empty cell display Select the For empty cells show check box. In the box, type the value that you want to display in empty cells. To display blank cells, delete any characters in the box.
If a cell is blank, the result is a status of "Open". The logical expression ="" means "is empty". In the example shown, column D contains a date if a task has been completed.
Check if value is empty in JavaScript Javascript Web Development Object Oriented Programming Use the condition with “” and NULL to check if value is empty. Throw a message whenever ua ser does not fill the text box value.
If a cell is blank, then it returns TRUE, else returns FALSE. Following examples will explain the difference to evaluate Blank or Not Blank cells using IF statement. To evaluate the cells as Blank, you need to use either logical expression Equal to Blank (=””) of ISBLANK function inthe logical_test argument of the IF formula.
Use the condition with “” and NULL to check if value is empty. Throw a message whenever ua ser does not fill the text box value.
Your example should work, but if you have whitespace or a function in o.Name it will not resolve to falsey and you will get an invisible space in the HTML rather than the desired dash.
A generic filter could be used to substitute empty values for dashes and apply various normalisation on the input first:
angular.module('App.filters', []).filter('placeholder', [function () {
return function (text, placeholder) {
// If we're dealing with a function, get the value
if (angular.isFunction(text)) text = text();
// Trim any whitespace and show placeholder if no content
return text.trim() || placeholder;
};
}]);
You can then use it as follows:
<th ng-repeat=" o in Odds" >{{o.Name | placeholder:'-'}}</th>
This is then completely reusable for other rows/columns and anywhere else you want to apply the same rule.
Example: http://jsfiddle.net/kfknbsp7/4/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With