Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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.

share|improve this question
    
What do you mean by "not working"? Both ngRouter and uiRouter work on all browsers. Which error stack are you getting? At first sight your code looks ok. Why do you use the same controller on all your routes? – Eloims Sep 1 '15 at 11:00
    
ngRouter and uiRouter now work in Chrome and Firefox, but the app just does not work in IE and safari? – Sole Sep 1 '15 at 11:04
    
Any error in the console? – Stefan Turcanu Sep 1 '15 at 11:04
up vote 4 down vote accepted

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

share|improve this answer
1  
That got the routing working... – Sole Sep 1 '15 at 11:15
    
@Sole Glad to help you THanks :) – Pankaj Parkar Sep 1 '15 at 11:17

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.