5

I'm currently working on an Angular 2 application and need to display some C# code in an Angular 2 template which will later be styled using a syntax highlighter.

However, as soon as I drop the code into an Angular 2 template I get template parse errors as it tries to parse the C# and fail.

zone.js:355 Unhandled Promise rejection: Template parse errors: <code>...

What is the solution to this? Does Angular 2 include ability to ignore the code portions of my template?

0

1 Answer 1

6
<code ngNonBindable>
  code here
</code>
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks! Out of interest, are there ways of escaping template reserved characters such as brackets and parenthesis?
As far as I know only {{}} to escape { and } like {{'{'}} and {{'}'}}.
Great, thank you. Thanks for the prompt reply too - I was taking part in a 3 day hackathon and with half an hour left this was a serious sticking point :D
You're welcome. Glad to hear :)
@ Günter, Thanks for answer but I am stucked here as How to write in .html template for the code as---<div> <code><pre> @Component({ selector: 'app-projection', templateUrl: './projection.component.html', styleUrls: ['./projection.component.css'] }) </code> <pre></div>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.