0

So I'm wanting to compile some JS code after the HTML is loaded.

var gifApp = angular.module('gifApp', []);

function MainCtrl ($scope) {
  $scope.push = function() {
    $("body").html("<div>{{ 1 + 1 }}</div>")
  }
}

Whenever the function push is called {{ 1 + 1 }} is displayed on the screen when I really want 2. Is it not possible to compile the code after the window is done loading? If it is possible, how do I fix this.

2
  • Maybe you're looking for "templates"? Commented Nov 19, 2013 at 0:49
  • I made a new question referencing specifically the problem I'm having. stackoverflow.com/questions/20061111/… Commented Nov 19, 2013 at 0:56

1 Answer 1

2

You are feeding the html() method a string, it is working correctly. I would change it to something like this:

var sum = 1 + 1;
$("body").html("<div>" + sum + "</div>");
Sign up to request clarification or add additional context in comments.

1 Comment

Hmm thanks. I have a different variation to the question but you answered it correctly.

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.