0

I have a simple HTML template like following

<p>{{data.id}}</p>

And can I just compile it with a data object to a string, I do not want to bind it with any scope.

Like

var data = {id:123}; 
var result = $compile(html)(data);

Thanks!

Added Plunker here.

4
  • Your plunkr code doesn't match your question. What are you trying to do? Bind properties without a scope? Angular won't do that. Are you trying to learn how to $compile some html and add it to your page? If so, please update your question. Commented Apr 29, 2015 at 16:46
  • It seems AngularJS does not support it.. I do not want scope Commented Apr 29, 2015 at 17:53
  • If you want to bind to a property, it must be on a scope. What's the problem with that? Commented Apr 29, 2015 at 18:26
  • never mind. I just tried to use angular as a template generator Commented Apr 29, 2015 at 18:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.