Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't include static json content as part of template html #10886

Closed
mlakmal opened this issue Aug 17, 2016 · 7 comments
Closed

Can't include static json content as part of template html #10886

mlakmal opened this issue Aug 17, 2016 · 7 comments
Labels
area: core Issues related to the framework runtime

Comments

@mlakmal
Copy link

mlakmal commented Aug 17, 2016

When we include json content as part of template html, we are getting template parsing errors like below. we use json content heavily in our current Angular v1 application to inject locale content to be used in directive html text labels.

Template parse errors:
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.) ("
}

Ex: page template html (use custom directive transcluded with json content)
`


{ "lblFName": "xyz" }

`

custom directive template html (we internally get the transcluded json content to vm.content variable and use it in the directive template)
<span>{{::vm.content.lblFName}}</span>

we are trying to research on upgrading our application to Angular2 with RC5 version but getting template parsing errors when trying to include json content like above. Do we have any other options to support this feature in Angular2 or allow us to override or add support to Angular2 template parser to ignore json content like above ...

Error message specifies, that we need to escape { char with '{', having to escape complex json content structure would be time consuming and we are looking for any other options are available in Angular2 for this...

@ericmartinezr
Copy link
Contributor

ericmartinezr commented Aug 17, 2016

Your best option is to use ngNonBindable ( https://github.com/angular/angular/blob/231ed695075b494d892c16e8c98765955b9d8868/modules/%40angular/common/test/directives/non_bindable_spec.ts ), although it sounds like a pita if you have to put that everywhere.

@mlakmal
Copy link
Author

mlakmal commented Aug 17, 2016

@ericmartinezr i already tried ngNonBindable, it doesn't ignore template parsing still throws same error.

@lukiffer
Copy link

+1, ran into the same issue where we're providing code examples. ngNonBindable was what we were using before, but it no longer works with >=RC5. Ended up just escaping as described, but it would be nice to have a simpler solution.

@zoechi
Copy link
Contributor

zoechi commented Aug 18, 2016

Plunker to reproduce?

@mlakmal
Copy link
Author

mlakmal commented Aug 18, 2016

@zoechi plunker url below

https://embed.plnkr.co/48KhM48Ru7lyxxob7LUw/

@pkozlowski-opensource
Copy link
Member

Duplicate of #11859. With #12178 you will be able to use ngNonBindable. There is more discussion on making it easier on people in #11859

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime
Projects
None yet
Development

No branches or pull requests

6 participants