1

I'm using AngularJs. I started to write simple controller that will output Hello world!

In my cribsControler.js code looked liked this:

angular
    .module('ngCribs')
    .controller('cribsController', function($scope){
            $scope.hello = 'hello world';
    });

and it worked. Then I changed my code to display details that are shown in the example below.

app.js

angular.module('ngCribs', ['ui.bootstrap']);

cribsController.js

angular
    .module('ngCribs')
    .controller('cribsController', function($scope){
            $scope.cribs = [
                {
                    "type": "condo",
                    "price": 22000,
                    "address": "nameOfStreet1",
                    "description": "description1"

                },
                {
                    "type": "hose",
                    "price": 54000,
                    "address": "nameOfStreet2",
                    "description": "description2"

                },
                {
                    "type": "cotage",
                    "price": 1000,
                    "address": "nameOfStreet3",
                    "description": "description3."

                }
                ];
    });

index.html

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
<title></title>
</head>

<body ng-app="ngCribs" ng-controller="cribsController">
<pre>{{ cribs | json}}</pre>

</body>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.2.0/ui-bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.2.0/ui-bootstrap-tpls.min.js"></script>
<script src="app.js"></script>
<script src="scripts/cribsController.js"></script>
</html>

When I edited, saved, and than ran it in a browser I got a blank page. When I clicked view page source and then when I clicked on my script link: <script src="scripts/cribsController.js"></script>, I can see that it didn't update from "Hello World" to the display details.

What can I do to actually update it? Or maybe there is error in my code?

1 Answers1

0

I development phase you should have the development console up. Press f12 to open It. Somewhere in the console you will find a setting that says something like: clear cache whille console is open(depends on which browser you use). Browser cache JavaScript files by default

Jens Alenius
  • 1,931
  • 2
  • 16
  • 20
  • great, but a correction from me. The setting should be something like:disable cache when dev console is open. If you use the operation clear cache you might loose cached data from other applications – Jens Alenius Aug 04 '17 at 22:32