I have several string variables:
var products = [
{
name: 'Product_1',
templateUrl: 'product_1'
},
{
name: 'Product_2',
templateUrl: 'product_2'
},
{
name: 'Product_3',
templateUrl: 'product_3'
},
{
name: 'Product_4 \n with extras',
templateUrl: 'product_4'
}
];
As you can see in product 4 i added a linebrea name: 'Product_4 \n with extras',
when i open up my html page:
<ion-list>
<ion-item class="item-icon-right" ng-repeat="product in products" ui-sref="app.{{product.templateUrl}}" >
{{product.name}}
</ion-item>
</ion-list>
There is no line break. the output is:
Product_1
Product_2
Product_3
Product_4 with extras
but it should be:
Product_1
Product_2
Product_3
Product_4
with extras
Why isnt the line break working?
ng-bind-html="product.name"
does not work as intented. As i mentioned i want the result to be:
Product_4
with extras
but with ng-bind-html="product.name"
and Product_4 <br /> with extras
the result is:
Prodcut 4
with extras
` won't work straightforward.That's because `ng-bind="suff"` - what `{{stuff}}` gets turned into - does not bind HTML. You need to use `ng-bind-html` explicitly. You'll have troubles with `$sce` too then. – Sergiu Paraschiv Jun 23 '15 at 14:08