Why can't I get the error module in JSFiddle?

I declare this module:

 angular.module('dashboard', [])
    .controller('dashboardController', ['$scope',
            function ($scope) {
                $scope.data = "555";
            }]);

And here is the view:

<div ng-app="dashboard" data-role="page" id="layersProperty" data-add-back-btn="true" >
    <div ng-controller="dashboardController">
            {{data}}
    </div>
</div>

And here is FIDDLE .

In the console, I get this error:

Error: [$ injector: nomod] The dashboard module is unavailable! You either mistakenly wrote the name of the module, or forgot to load it. If registering a module ensures that you specify the dependencies as the second argument.

Any idea why I get the error above?

+4
source share
3 answers

There is no problem with your code, since you are adding external scripts, you just need to change

Javascript settings -> Load type -> Wrap in <Head> enter image description here

+3
source

, javascript JSFiddle. onLoad, JSFiddle javascript $(window).load(function (){});. , angular.module(), Angular, , DOM . Angular dashboard, .

+1

Basically, your code looks good and, by the way, its working Plnkr check .

check your code (did you enable angular?) or just post the full code.

code in Plnkr:

<!DOCTYPE html>
<html>

<body>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

  <div ng-app="dashboard" ng-controller="dashboardController">
    {{ data }}
  </div>

  <script>
    angular.module('dashboard', [])
      .controller('dashboardController', ['$scope',
        function($scope) {
          $scope.data = "555";
        }
      ]);
  </script>

</body>

</html>
0
source

Source: https://habr.com/ru/post/1680662/


All Articles