Search code examples
javascriptangularjsroutesangularjs-routingangular-ui-router

Angular JS - UI-router not working


router working within my Angular JS app. My code is:

Script:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.min.js"></script>

HTML:

<div ui-view></div>

app.js:

var myApp = angular.module('myApp', ['ui-router','mainControl','ui.bootstrap', 'ngSanitize']);
myApp.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/splash');
  //
  // Now set up the states
  $stateProvider
    .state('splash', {
      url: '/splash',
      templateUrl: 'partials/splash2.html',
      controller: 'MainControl'
    })
    .state('advice', {
      url: '/advice',
      templateUrl: 'partials/advice.html',
      controller: 'MainControl'
    })
    .state('main', {
      url: '/main',
      templateUrl: 'partials/main.html',
      controller: 'MainControl'
    })
    });

I was has successfully integrated ngRoute into my project, but for some reason the routing was not working in Safari and IE, So this is why I am now trying to integrate the UI-router into my project so that I can successfully get the routing working within my Application.

Any help would be appreciated.


Solution

  • You are having typo, module name should be ui.router instead of ui-router while creating myApp module for your app.