samedi 25 juin 2016

Angularjs Route loading error

I wondered if you could help.

I am learning Angularj and have decided to make use of the Angular Route lib. I keep getting an error when trying to load it.

 angular.js:38Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.0/$injector/modulerr?p0=jargonBuster&p1=Err…loudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.3.0%2Fangular.min.js%3A18%3A3)

Here is my code, I have changed up the links to the see what works with no enjoy.

HTML

<!DOCTYPE html>
<html ng-app = "jargonBuster">
<head>
<meta charset="utf-8">
<title>Angular.js Example</title>
<link type="text/css" rel="stylesheet" href="style.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular-route.js"></script>

</head>
<body>
<section ng-controller="MainCtrl"></section><!-- VIEW -->


</body>
</html>
<script src="script.js"></script>

JS

var app = angular.module('jargonBuster', ['ngRoute']); 

//router
app.config(function($routeProvider) {
    $routeProvider.
    when('/', {
        templateUrl:'keyword-list.html',
        controller: 'MainCtrl'
    }).
    otherwise({
        redirectTo: '/'
    });
});


// The Controller
app.controller('MainCtrl', function($scope, $http) {
    $http.get("getdecks.php").success(function(data) { //Gets data from The Decks Table
        $scope.deckData = data;});
    $http.get("getcards.php").success(function(data) { //Gets data from The Cards Table
        $scope.cardsData = data;});

    $scope.sortField = 'keyword';   
    $scope.reverse = true;

});// End of the controller

Thanks, any ideas?

Aucun commentaire:

Enregistrer un commentaire