Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular variable not being show properly on webpage

Just as the title suggests, I'm trying to self learn Angular.js but I run into an unexpected frustrating road block... I can't even get the variables to display properly on the webpage!

<!DOCTYPE html>
<html ng-app>
<head>
    <title>Lets test this out?</title>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
</head>
<body>

    Write your name in the text box!
    <input type="text" ng-model="sometext" />    
    <h1>Hello {{ sometext }}</h1>

</body>
</html>

I'd greatly appreciate anyone that can tell me what I am doing wrong as I've been beating my head against my desk for an hour and googled this issue but I can't understand why it doesn't work.

like image 242
K. Awuah Avatar asked Jun 05 '26 10:06

K. Awuah


1 Answers

Check your angular reference has been loaded properly. Try to add ng-app to your body tag

DEMO

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app>
    Write your name in the text box!
   <input type="text" ng-model="sometext" />
   <h1>Hello {{ sometext }}</h1>
</body>
like image 181
Sajeetharan Avatar answered Jun 07 '26 00:06

Sajeetharan