Yian
Yian

Reputation: 199

Basic routing using ionic

For some reason, I keep getting a 404 (cannot be found) for my wardrobes.html file. The other files work fine (such as login.html and cards.html).

I've read through documentation & examples- still cannot figure this one out.

Do I need to tell AngularJS to allow my HTML file? In the same dir, I've added a .js file to index.html which can be found

routes.js

angular.module('stashd.routes', [])

.config(['$stateProvider', '$urlRouterProvider',
    function($stateProvider, $urlRouterProvider) {

        $urlRouterProvider.otherwise("/login");

        $stateProvider

            .state('login', {
                url: '/login',
                views: {
                    'menuContent': {
                        templateUrl: 'app/core/login/login.html'
                    }
                },
                controller: function ($ionicHistory, $scope) {
                    console.log('Clearing history!');
                    $ionicHistory.nextViewOptions({
                        historyRoot: true,
                        disableBack: true
                    });
                }
            })

            .state('wardrobes', {
                url: '/wardrobes',
                views: {
                    'menuContent': {
                        templateUrl: 'app/components/wardrobes/wardrobes.html'
                    }
                },
            })
            //What does menuContent do?

            .state('cards', {
                url: '/',
                views: {
                    'menuContent': {
                        templateUrl: 'app/components/cards/cards.html'
                    }
                }
            });
    }
])

wardrobes.html

<ion-view name="wardrobes">
  <!-- The title of the ion-view will be shown on the navbar -->
  <ion-view view-title="wardrobes">
    <ion-content ng-controller="WardrobesCtrl">
      <!-- The content of the page -->
     <h1>This page working or not?!>
    </ion-content>
  </ion-view>
</ion-view>

Chrome console & directory of code

Chrome console & directory of code

Upvotes: 1

Views: 69

Answers (1)

FLCL
FLCL

Reputation: 2514

As you can see, you have mistake in name of the html file:

wardobes.html

in place of

wardrobes.html

Upvotes: 1

Related Questions