0
votes

Uncaught Error: [$injector:modulerr] Failed to instantiate module myModule due to: Error: [$injector:nomod] Module 'myModule' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

    <head>
    <script src="Scripts/angular.js"></script>
    <script src="Scripts/Script.js"></script>
   </head>

   <body ng-controller="myController">
    <div>
        <table>
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Likes</th>
                    <th>DisLikes</th>
                    <th>Likes/DisLikes</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="technology in technologies">
                    <td>{{ technology.name }}</td>
                    <td>{{ technology.likes }}</td>
                    <td>{{ technology.dislikes }}</td>
                    <td>
                        <input type="button" value="Like" ng-click="incrementLikes(technology)">
                        <input type="button" value="Dislike" ng-click="incrementDislikes(technology)">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>

   </body>
</html>




 var app = angular.module("myModule", [])



            app.controller("myController", function($scope){
                    var technologies = [{name:"C#", likes:0, dislikes:0},
                    {name:"ASP.NET", likes:0, dislikes:0},
                    {name:"SQL Server", likes:0, dislikes:0},
                    {name:"Angular JS", likes:0, dislikes:0},];

                    $scope.technologies = technologies;

                    $scope.incrementLikes = function(technology){
                        technology.likes++;
                    }

                    $scope.incrementDislikes = function(technology){
                        technology.dislikes++;
                    }


         });
2
We cant help you unless you post the Script.js file as well...Gal Silberman
Its already given belowAbhishek Kumar

2 Answers

2
votes

You have not defined ng-app="myModule" in your html template.

Either define it in html or body tag then it should start working.

0
votes

Just add ng-app="myModule" to your HTML ,

<body ng-app="myModule" ng-controller="myController">

DEMO

var app = angular.module("myModule", [])
app.controller("myController", function($scope){
 var technologies = [{name:"C#", likes:0, dislikes:0},
                    {name:"ASP.NET", likes:0, dislikes:0},
                    {name:"SQL Server", likes:0,dislikes:0},
                    {name:"Angular JS", likes:0, dislikes:0},];
$scope.technologies = technologies;
$scope.incrementLikes = function(technology){
       technology.likes++;
}
 $scope.incrementDislikes = function(technology){
          technology.dislikes++;
 }
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
 <body ng-app="myModule" ng-controller="myController">
    <div>
        <table>
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Likes</th>
                    <th>DisLikes</th>
                    <th>Likes/DisLikes</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="technology in technologies">
                    <td>{{ technology.name }}</td>
                    <td>{{ technology.likes }}</td>
                    <td>{{ technology.dislikes }}</td>
                    <td>
                        <input type="button" value="Like" ng-click="incrementLikes(technology)">
                        <input type="button" value="Dislike" ng-click="incrementDislikes(technology)">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
   </body>