Monday, 10 April 2017

unable to load the angular js module getting angular.js:38 Uncaught Error: [$injector:modulerr]

initially i figured that it`s may be because of the ngRoute module so I have added the dependency as well even though getting the same error.as a beginner this is eating my head .... guys any help

index.html

   <!DOCTYPE html>
<html ng-app="myApp">

<head>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
    <title>Contact List Application</title>

</head>

<body>
    <div class="container"  ng-controller="AppCtrl">
        <h1>Contact List for Members</h1>
        <table class="table">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Email</th>
                    <th>contact</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="contact in contactlist">
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            </tbody>

        </table>
    </div>

    <script  src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular.min.js"></script>
    <script  src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular-route.min.js"></script>

    <script  src="controllers/controller.js">

    </script>
</body>

</html>

controller.js

angular.module('myApp', ['ngRoute'])
     .controller('AppCtrl', function AppCtrl($scope) {


        person1 = {
            name: 'tm',
            email: 'tm@gmail.com',
            number: '(111) 222-2222'
        };
        person2 = {
            name: 'dk',
            email: 'dik@gmail.com',
            number: '(111) 222-2223'
        };
        person3 = {
            name: 'hey',
            email: 'hey@gmail.com',
            number: '(111) 222-2224'
        };

        var contactlist = [person1, person2, person3];
        $scope.contactlist = contactlist;
    });

testing the code on online code compiler its working fine but when I am running this code in node server localhost its throwing the above error.



via NAVEEN jaiswar NEO

No comments:

Post a Comment