Как идентифицировать и экранировать символы, используемые в тексте внутри HTML-элемента ngNonBindable в Angular? - PullRequest
0 голосов
/ 13 февраля 2019

Я использую Angular7, мой HTML-контент выглядит следующим образом.

<code ngNonBindable>
        app.get('/aaa/bbb', function(req, res) {
          if (!req.headers.authorization) {
          return res.json({ error: 'No Access!' });
          }
          if (req.headers.accessToken != "Hello") {
          return false;
          }
        });
</code>

Я получаю следующую ошибку:

compiler.js:2547 Uncaught Error: Template parse errors:
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.) (</p>
</div>[ERROR ->]"): ng:///AppModule/HowToFixDialogComponent.html@359:6
Invalid ICU message. Missing '}'. ("

    <code ngNonBindable>
    app.get('/aaa/bbb', function(req, res) [ERROR ->]{
      if (!req.headers.authorization) {
      return res.json({ error: 'No Access!"): ng:///AppModule/HowToFixDialogComponent.html@272:57
at syntaxError (compiler.js:2547)
at DirectiveNormalizer.push../node_modules/@angular/compiler/fesm5/compiler.js.DirectiveNormalizer._preparseLoadedTemplate (compiler.js:14102)
at compiler.js:14094
at Object.then (compiler.js:2538)
at DirectiveNormalizer.push../node_modules/@angular/compiler/fesm5/compiler.js.DirectiveNormalizer._preParseTemplate (compiler.js:14094)
at DirectiveNormalizer.push../node_modules/@angular/compiler/fesm5/compiler.js.DirectiveNormalizer.normalizeTemplate (compiler.js:14080)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.loadDirectiveMetadata (compiler.js:17282)
at compiler.js:24906
at Array.forEach (<anonymous>)
at compiler.js:24905

Какие символы вызывают проблему и как их избежать?

...