4

Using AngularJS, the following html code prints {{1+1}} instead of 2

<!doctype html>
<html lang="en" ng-app="myApp">
<head>
    <script src="/js/angular.min.js"></script>
</head>
<body>
{{1+1}}
</body>
</html>

While if I remove "myApp" like below, it prints 2 correctly.

<!doctype html>
<html lang="en" ng-app>
<head>
    <script src="/js/angular.min.js"></script>
</head>
<body>
{{1+1}}
</body>
</html>
1
  • My question is why the first one is not working. Commented May 21, 2012 at 5:26

1 Answer 1

8

Because you don't specify the module myApp so it blows up on the error.

Open web inspector console to see it.

// adding this will fix it
angular.module('myApp', []);
Sign up to request clarification or add additional context in comments.

Comments

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.