Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS parser is not activatied when application name is provided

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>
like image 537
Ali Salehi Avatar asked Feb 21 '23 10:02

Ali Salehi


1 Answers

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', []);
like image 145
Vojta Avatar answered May 01 '23 13:05

Vojta