Search code examples
javascriptangularjsroutesangularjs-routing

Angular simple single page app - Unknown provider: $routeProvider


I'm sure this is really simple and I'll get down voted but any help would be greatly apprecicated.

I have a plunker here

https://plnkr.co/edit/5tDXBPt4Ff3mM4ac5hWK?p=preview

I'm setting up a simple single page app.

I'm getting an error in the console.

Error: $injector:unpr
Unknown Provider
Unknown provider: $routeProvider

Solution

  • ngRoute isn't a depedendency, its a angular module(remove ngRoute from from your config function). You should be injecting it with inside app module depedency array.

    angular.module('cxoJsApp',['ngRoute']);
    

    Also make sure, when you are using angular API, they both should be of same version, like here you are using angular-route.js older version(1.2.x). You should use latest version of angular API's. So you should use 1.4.8 version for both angular.js & angular-route.js

    Apart from that you had missed to refer app.js on the page. Also add missing controllers in the file

    Wokring Plunkr