mercredi 4 novembre 2015

angularjs injector modulerr issue when using angular ui grid

I have used angularjs ui grid in my MVC application. below is my code:

<script src="@Url.Content("~/Scripts/AngularGrid/angularjs.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/AngularGrid/angular-ng-route.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/AngularGrid/uigrid.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/ui-grid.min.css")" rel="stylesheet" type="text/css" />
<script src="../../Scripts/AngularGrid/jquery-1.10.2.min.js" type="text/javascript"></script>

 <div ng-app = "myapp" ng-controller="HelloController">
      <div id="grid1" ui-grid="{ data: myData }" class="grid"></div>
    </div>
      
<script type="text/javascript">
    var StudentApp = angular.module('myapp', ['ui.grid']);

    StudentApp.controller('HelloController', function ($scope, StudentService) {
        $scope.columnDefs = [
 { field: 'FirstName', title: 'fname' },
 { field: 'Last Name' },
 { field: 'Salary' },
 { field: 'DOB' }
 ],
        getStudents();
        function getStudents() {
            StudentService.getStudents()
            .success(function (studs) {
                $scope.myData = studs;
                console.log($scope.students);
            })
            .error(function (error) {
                $scope.status = 'Unable to load customer data: ' + error.message;
                console.log($scope.status);
            });
        }
    });

    StudentApp.factory('StudentService', ['$http', function ($http) {
        var StudentService = {};
        StudentService.getStudents = function () {

            return $http.get('/DutyTravel/GetCityDetails');
        };
        return StudentService;

    } ]);
</script>

See this error message found in chrome console

Getting angularjs injector modulerr

same i created with new mvc 3 application it is working fine.

and the same logic i used in my existing mvc application getting this error. Need help.

Aucun commentaire:

Enregistrer un commentaire