1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>

<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script type="text/javascript" src = "js/angular.min.js"></script>
<script type="text/javascript" src = "js/angular-route.js"></script>
<script type="text/javascript" src = "js/angular-resource.min.js"></script>
<script type="text/javascript" src = "js/script.js"></script>

</head>

<body ng-app>
<div>
{{Hello World!}}
</div>

<script src="js/bootstrap.min.js"></script>
</body>
</html>

script.js

if(typeof angular == 'undefined' )
{
alert("not working");
}
else
{
alert("good");
}

I get alerted good, although the page still has

{{Hello World!}}

What am I missing here? I thought the binding was supposed to work by itself. I am using angular js 1.2.16 btw

//extra characters because stackoverflow wouldn't let me post the question. Says too much code.

2 Answers 2

1

All included scripts are good. However you are not telling angular where to start bootstraping your angular application.

You are missing ng-app directive on the html tag.

<html ng-app>

Also the Hello World should be a string.

{{"Hello World!"}}
Sign up to request clarification or add additional context in comments.

1 Comment

Aah! It has to be a string. Totally missed that. Thanks! :). Btw I have given ng-app directive on body. so it's supposed to be working even with that. IMO It's not necessary to give it on html tag always. Thanks anyways. :)
0

Working example :

script.js

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

index.html page:

<!DOCTYPE html>
<html ng-app="MyTestApp">
<head>

2 Comments

shouldn't it be angular.module("LoginApp",[]); ?
This still doesn't work. Anything inside {{}} has to be a string. That was the error. What you did wasn't really necessary. Anyways thanks.

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.