Bomani Kernizan Bomani Kernizan - 1 year ago 118
AngularJS Question

UI routes not working

I can't seem to get my angular app to work with routes. The basic app itself works but breaks the moment I try to add in routes

Here's a link to the plunker: broken routes

var app = angular.module('appModule', ['ui.router']).config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $urlRouterProvider) {


.state('home', {
url: '/home',
templateUrl: 'home.html'
controller: 'homeController'})}])

app.controller('homeController', ['$scope', function($scope) {$scope.hello = "flarg";}])

and here is the the same simple app without routes link to plunker here: working app

Answer Source

You configuration should be like this,

var myApp = angular.module("myApp", ['ui.router']);
myApp.config(function($stateProvider, $urlRouterProvider) {
  $urlRouterProvider.when("", "/home");
    .state("home", {
      url: "/home",
      templateUrl: "home.html",
      controller: 'homeController'
myApp.controller('homeController', ['$scope', function($scope) {
  $scope.hello = "flarg";


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download