This is index.html file
<!doctype html>
<html ng-app="mm">
<head>
<title>Country page</title>
<script src="js/angular.js"></script>
<link href="js/bootstrap.css" rel="stylesheet" />
<link href="js/bootstrap-theme.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet" />
<script src="app.js"></script>
<style>
.box {
margin:0px auto;
width: 400px
}
</style>
</head>
<body>
<div class="box" ng-controller="mc">
<p ng-if="bool">Hello!!!</p>
</div>
</body>
</html>
This is app.js file
var mm = angular.module('mm', []);
var mc = mm.controller('mc', function ($scope){
$scope.bool = false;
});
I am very beginer at AngularJS and I am confused why "Hello!!!" still on my page but my bool variable is "false".
asked Jul 6, 2015 at 19:15
Dmitry
3311 gold badge3 silver badges10 bronze badges
-
Your code is working. AngularJS is not loaded!Sudhansu Choudhary– Sudhansu Choudhary2015年07月06日 19:35:01 +00:00Commented Jul 6, 2015 at 19:35
-
which version of angular are you using in this example?Claies– Claies2015年07月06日 19:57:21 +00:00Commented Jul 6, 2015 at 19:57
3 Answers 3
You are doing correctly everything, May be you should check if angular is loaded, (with console.log(angular) ).
It does work for me: https://jsfiddle.net/shimonb/h44rduky/3/
answered Jul 6, 2015 at 19:24
Shimon Brandsdorfer
1,7239 silver badges25 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Try to change your tag to <div ng-show="bool">Hello!!</div>
answered Jul 6, 2015 at 20:21
wmaxlees
6051 gold badge5 silver badges22 bronze badges
Comments
I just set up AngularJS version 1.4.2 and now everything is ok! Thanks all for help!
answered Jul 7, 2015 at 6:11
Dmitry
3311 gold badge3 silver badges10 bronze badges
Comments
lang-js