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

Angularjs version 1.3.14, ui-router version 0.2.15, html5mode enabled. When I try http://localhost/firsttime it redirects to http://localhost as fallback

Here is app.js

'use strict';

// Declare app level module which depends on views, and components
angular.module('tt', [
  'ngRoute',
  'tt.home',
  'tt.firsttime',
  'ui.router'
])

.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
    // Routes
    $routeProvider.otherwise({
        redirectTo: '/'
    });

    // set HTML5 history API
    $locationProvider.html5Mode(true);
}]);

Here is firsttime.js

// create our angular app and inject ngAnimate and ui-router 
// =============================================================================
angular.module('tt.firsttime', ['ui.router'])

// configuring our routes 
// =============================================================================
.config(['$stateProvider', '$urlRouterProvider', '$routeProvider', function($stateProvider, $urlRouterProvider, $routeProvider) {
    // catch all route
    // send users to the form page 
    $urlRouterProvider.otherwise('/firsttime');

    $stateProvider
        // route to show our basic form (/firsttime)
        .state('firsttime', {
            url: '/firsttime',
            templateUrl: 'firsttime/form.html',
            //controller: 'formController'
        })
}])

// our controller for the form
// =============================================================================
.controller('formController', ['$scope', function($scope) {
    console.log('FORM controller');
}]);

And here is form.html

<div class="row">
<div class="col-sm-8 col-sm-offset-2">

  <div id="form-container">

      <div class="page-header text-center">
          <h2>Let's Be Friends</h2>

          <!-- the links to our nested states using relative paths -->
          <!-- add the active class if the state matches our ui-sref -->
          <div id="status-buttons" class="text-center">
              <a ui-sref-active="active" ui-sref="firsttime.profile"><span>1</span> Profile</a>
              <a ui-sref-active="active" ui-sref="firsttime.interests"><span>2</span> Interests</a>
              <a ui-sref-active="active" ui-sref="firsttime.payment"><span>3</span> Payment</a>
          </div>
      </div>

      <!-- use ng-submit to catch the form submission and use our Angular function -->
      <form id="signup-form" ng-submit="processForm()">
          <!-- our nested state views will be injected here -->
          <div id="form-views" ui-view></div>
      </form>

  </div>



</div>
</div>

Update Here is the nginx routing block

    location / {
        root   html/app;
        index  index.html;
        try_files $uri /index.html;
    }
share|improve this question
up vote 1 down vote accepted

Remove the config block from the app.js that may conflicting with your current route system. You should never use both routing engine together. By looking at your code it seems like you are trying to use ui-router for routing. So by removing app.js config block will potentially solve your issue.

The issue is because of this line

$routeProvider.otherwise({
    redirectTo: '/'
});

After removing code from the app.js you should move below lines to firsttime.js config block, this will enable the html5mode

// set HTML5 history API
$locationProvider.html5Mode(true);
share|improve this answer
    
Had tried, no luck! Has it something to do with nginx config? Updated orig post – Dewsworld Jul 25 at 7:49
    
@Dewsworld that the issue you need to fix on nginx side.. I;m not familliar with it.. Sorry – Pankaj Parkar Jul 25 at 8:00
    
I believe the error was due to mixing routeprovider and stateprovider. Upgraded to ui-router, since it looks more promising than ngRoute – Dewsworld Jul 25 at 9:12
    
@Dewsworld that what I suggested in my answer.. you are using ui-router remove the ngRoute thing thoroughly – Pankaj Parkar Jul 25 at 9:14
    
@Dewsworld Glad to help you..Thanks :) – Pankaj Parkar Jul 25 at 9:28

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.