0

I'm having trouble finding out why ngRouts doesn't include the views i have set.

When i look at the javascript console i do get the following error.

Error: unknown provider.

I looked that up and came to posts about not using the angular-route.js file. But i am using this file so what's going on here?

Failed to instantiate module [$injector:unpr] Unknown provider: $routeProvider

HTML

<div data-ng-app="klantenModule">
  <!--placeholder for the views -->
  <div data-ng-view=""></div>   
</div>

<script src="scrips/angular.js"></script>
<script src="scrips/script.js"></script>
<script src="scrips/angular-route.js"></script>

JS

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

klantenModule.config(['$routeProvider', function ($routeProvider) { 
  $routeProvider.when('/', 
    { controller: 'klantenController', 
      templateUrl: 'partials/view1.html'})

  $routeProvider.when('/view2', 
    { controller: 'klantenController',
      templateUrl: 'partials/view2.html'})

  $routeProvider.otherwise( { redirectTo: '/'})
}])

klantenModule.controller( 'klantenController', klantenController)

function klantenController($scope) {
  $scope.klantenLijst =
    [
      { naam:'liselore', woonplaats: 'blankenberge' }, 
      { naam:'harold', woonplaats:'brugge'},
      { naam:'kevin', woonplaats:'brugge'}
    ]
  $scope.klantenToevoegen = function(){
    $scope.klantenLijst.push({ woonplaats: $scope.klanten.woonplaats, naam: $scope.klanten.naam})
  }
}
Community
  • 1
  • 1

1 Answers1

0

I think the order of your declaration of script is incorrect. Try this

<script src="scrips/angular.js"></script>
<script src="scrips/angular-route.js"></script>
<script src="scrips/script.js"></script>

Assuming that script.js is the file where routes are defined.

Chandermani
  • 42,589
  • 12
  • 85
  • 88