Dmitry
Dmitry

Reputation: 331

AngularJS if statment

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".

Upvotes: 2

Views: 50

Answers (3)

Dmitry
Dmitry

Reputation: 331

I just set up AngularJS version 1.4.2 and now everything is ok! Thanks all for help!

Upvotes: 0

wmaxlees
wmaxlees

Reputation: 605

Try to change your tag to <div ng-show="bool">Hello!!</div>

Upvotes: 1

Shimon Brandsdorfer
Shimon Brandsdorfer

Reputation: 1723

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/

Upvotes: 1

Related Questions