Search code examples
angularjsangular-ui-routerwakanda

wakanda angular $urlRouterProvider stateProvider


I begining on Wakanda Angular. And I have a problem for to change page. When I opening my application, I would like arrive new.html page. Anyone can help me?

app.js:

angular.module('starter', ['ionic', 'wakanda']) 

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

.config(function ($stateProvider, $urlRouterProvider){
    $stateProvider
    .state('home',{
        url:'/home',
        templateUrl:'view/home.html',
        cache:false
    })
    .state('new', {
      url: '/new',
      controller: 'NewController',
      templateUrl: 'view/new.html',
      cache: false
    })
    $urlRouterProvider.otherwise('new');
})

.controller('NewController', function($scope, $state) {
    console.log("test");
});##

Solution

  • I edited my answer, can you please try the code below, change the url: to '/' and also the url in $urlRouterProvide

    .config(function ($stateProvider, $urlRouterProvider){
            $stateProvider
            .state('home',{
                url:'/home',
                templateUrl:'view/home.html',
                cache:false
            })
            .state('new', {
              url: '/',
              controller: 'NewController',
              templateUrl: 'view/new.html',
              cache: false
            })
            $urlRouterProvider.otherwise('/');
        })