Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 539
Sole Avatar asked Feb 21 '26 06:02

Sole


2 Answers

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

like image 164
Pankaj Parkar Avatar answered Feb 22 '26 19:02

Pankaj Parkar


Besides ui.router, you should add the js file for ngSanitize (<script src="angular-sanitize.js">)

like image 28
Stefan Turcanu Avatar answered Feb 22 '26 21:02

Stefan Turcanu