hollyquinn
hollyquinn

Reputation: 652

AngularJS Cannot read property 'otherwise' of undefined

Hi I am brand new to Angular, I'm working through a tutorial and I've run into an error when trying to set a default route. The error is Uncaught Error: [$injector:modulerr] Failed to instantiate module productManagement due to: TypeError: Cannot read property 'otherwise' of undefined. My code is below.

(function () {
"use strict";
var app = angular.module("productManagement", ["common.services", "ui.router", "productResourceMock"]);

app.config(["$stateProvider",
    function ($stateProvider, $urlRouterProvider) {
        $urlRouterProvider.otherwise('/products');
        $stateProvider
        .state("productList", {
            url: "/products",
            templateUrl: "app/products/productListView.html",
            controller: "ProductListCtrl as vm"
        })
    }]

    );
}());

Can anyone help a newbie out?

Upvotes: 0

Views: 1240

Answers (1)

Anid Monsur
Anid Monsur

Reputation: 4538

Your injector array is missing the $urlRouterProvider. All dependencies must be listed there.

app.config(["$stateProvider", "$urlRouterProvider",
    function ($stateProvider, $urlRouterProvider) {
      ...
}]);

Upvotes: 2

Related Questions