1

How can I tell to angular to display the html code to display the flag picture only if the variable that contains the name of the flag is not empty. The name of the flag is in column.field of a ng-grid.

The code below doesn't work correctly:

var CellTemplate = '<div>{{row.getProperty(col.field)? "<img ng-src=\'images/country/flag_{{row.getProperty(col.field)}}.gif\' />" : ""}}</div>';

The result is displaying like that: {{row.getProperty(col.field)? "flag picture" : ""}}

2
  • can you provide jsfiddle? Commented Sep 14, 2015 at 16:18
  • You are passing the entire operation as a string. You should do it how you would in plain JS Commented Sep 14, 2015 at 16:20

1 Answer 1

2

You can't put html within {{}} view expressions. Those expressions only support text.

Try using ng-if:

<div ng-if="row.getProperty(col.field)">
      <img ng-src='images/countryflag_{{row.getProperty(col.field)}}.gif' />
</div>
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.