2

As the syntax for angular expressions and Handlebars expressions are same ({{ }}), I am wondering whether we can use both simultaneously or not.

halfer
  • 19,824
  • 17
  • 99
  • 186
Sudhir K
  • 37
  • 1
  • 7
  • 1
    Why would you want to do that ? for backend or only frontend ? Generally using two different library with the same syntax is a terrible idea – Milad Feb 21 '17 at 10:38
  • 1
    If you really must use Handlebars (which I don't think is a very good idea) you can use http://stackoverflow.com/questions/39819407/interpolateprovider-in-angularjs-2/39819519#39819519 – Günter Zöchbauer Feb 21 '17 at 11:20

1 Answers1

0

In some cases it would make sense to use handlebars in the front-end. But probably not for what you think.

  • e.g. If you have a website that creates commands, invoices or reports, and you want your users to create custom layouts for those documents, then you could offer them handlebars templates.

  • e.g. If your website is actually a code generator tool, then you could let users tweak their output using handlebar scripts.

So, on that level, yes you can use handlebars.

By contrast, don't use it to actually render the html of your angular components. That would be a terrible idea.

However, if you really really wanted to do that, you could. After all, you can inject a variable which contains html directly inside your angular component templates. Of course it would be extremely limited.

<div [innerHTML]="htmlstring"></div>
bvdb
  • 22,839
  • 10
  • 110
  • 123