Shanto Siddiq
Shanto Siddiq

Reputation: 153

When i try to refresh my page i have this error

error .Uncaught SyntaxError: Invalid shorthand property initializer angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.5/$injector/modul

This is my app.js code:

var myApp = angular.module("myapp", ["ngRoute"]);

myApp.controller("myController", function($scope){
console.log("This is app.js ...........");

$scope.users = [
    {username="John" , email="[email protected]"},
    {username="Adam" , email="[email protected]"}
];
});

This is my index.html code:

    <!DOCTYPE html>
<html lang="en-US">
<link rel="stylesheet"
    href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
    integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
    crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

<body ng-app="myApp" ng-controller="myController">
    <div class="container">

        <button type="button" class="btn btn-primary pull-right"
            data-toggle="modal" data-target="#myModal">Add Product</button>
        <h2>Product List</h2>



        <table class="table table-striped">
            <thead>
                <tr>
                    <th>Index</th>
                    <th>UserName</th>
                    <th>Email</th>
                    <th>Edit</th>
                    <th>Delete</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="user in users">
                    <td>{{$index+1}}</td>
                    <td>{{user.username}}</td>
                    <td>{{user.email}}</td>
                    <td>
                        <button type="button" class="btn btn-warning" data-toggle="modal"
                            data-target="#myModalEdit">Edit</button>
                    </td>
                    <td>
                        <button type="button" class="btn btn-danger" data-toggle="modal"
                            data-target="#myModalDelete">delete</button>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html>

Upvotes: 2

Views: 187

Answers (2)

Shashank Vivek
Shashank Vivek

Reputation: 17514

Fix ng-app="myApp" to ng-app="myapp" in html file. check this plunkr

var myApp = angular.module("myApp", []);

myApp.controller("myController", function($scope){
console.log("This is app.js ...........");

$scope.users = [
    {username: "John" , email:"[email protected]"},
    {username:"Adam" , email:"[email protected]"}
];
});

Upvotes: 4

Melchia
Melchia

Reputation: 24304

That's not the way to declare an object. Replace = with :

$scope.users = [
    {username:"Shanto" , email:"[email protected]"},
    {username : "Adam" , email : "[email protected]"}
];

Upvotes: 1

Related Questions