How can I bind a text which contains url as html

Issue

How can I bind a text which contains url as html. Is it possible by using the following code ?

@CustomTag('my-element')
class MyElement extends PolymerElement {      
  @observable String text = "Bla bla bla '<a href="mysite.com">link</a>';"

  MyElement.created() : super.created();
}
<polymer-element name="my-element">
  <meta charset="utf-8">
  <template>
  <p>
   {{text}}
  </p>
  </template>
  <script type="application/dart" src="my_element.dart"></script>
</polymer-element>

Solution

Update

A ready-to-use element for Dart Polymer 1.0 is bwu-bind-html


No you can’t bind html using mustache.

what you can do is

<a href="{{text}}">link</a>

with a field like

@observable String text = "mysite.com";

or use something like a <safe-html> tag – see HTML Tags Within Internationalized Strings In Polymer.dart

Answered By – Günter Zöchbauer

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.