$ state.go () works without error but doesn't actually work w / Ionic

I'm just trying to get the state to transition to a new template after running a function to ng-change from a set of options.

My function works fine after being selected, but the $ state.go () that gets called at the end of the function doesn't actually change the state to the next kind of state I want to go to.

Below is my code (simplified). I want to select and option in "template / pages / addit / index.html", run the function, and then change the state to "template / pages / addit / edit.html".

app.js:

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

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

.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/pages/menu/index.html",
controller: 'AppController'

.state('app.addit', {
url: "/addit",
views: {
  'menuContent': {
    templateUrl: "templates/pages/addit/index.html",
    controller: 'AddItController'
  }
}})

.state('app.addit.edit', {
url: "/edit",
views: {
    templateUrl: "edit.html",
    controller: 'EditItController'
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app/addit');
});

      

add-on it-controller.js:

angular.module('starter')
.controller('AddItController', function($scope, $state, addInventory){

$scope.selectNum = function (num) {
  addInventory(num) //works fine
  $state.go('addit.edit');//doesn't actually change the state
  console.log('the state is '+$state.current);

}
});

      

Templates / pages / supplements from grow /index.html

   <ion-view view-title="Addit">
  <ion-content>
  <div class="list card">

       <label class="item item-input item-select">
          <div class="input-label">
            How many?
          </div>
          <form >
            <select ng-change='selectNum(num)' ng-model="num"  required>

              <option  value='1'  selected>1</option>
              <option  value='2' >2</option>

            </select>
        </form>
      </label>
  </ion-content>
</ion-view>

      

+3


source to share


2 answers


Maybe $ state.go ('app.addit.edit') will do the trick in your controller. You have skipped to provide all the statistics.



+4


source


Actually it turned out to be a problem with app.js where I should have had:

 .state('app.edit', {
    url: "/addit/edit",
    views: {
      'menuContent': {
        templateUrl: "templates/pages/addit/editphotos.html"
      }
    }
  });

      



What I did before was trying to create a state for the edit page without including it as a sub-state "menuContent"

+2


source







All Articles