Angular-fullstack ui-router没有正确路由到父状态

时间:2015-03-12 07:55:51

标签: javascript angularjs angular-ui-router angular-fullstack

当处于特定药物的编辑状态时,$state.go('^');出现问题。 奇怪的是,当我点击保存按钮时,它会通过main.detail状态返回主状态。 我正在使用angular-fullstack。

main.js

'use strict';

angular.module('aidkitApp')
  .config(function ($stateProvider) {
    $stateProvider
      .state('main', {
        url: '/',
        templateUrl: 'app/main/main.html',
        controller: 'MainCtrl',
        ncyBreadcrumb: {
          label: 'Lista Leków'
        }
      })
      .state('main.detail',{
        url: '{medicationId}',
        views: {
          "@" : {
            templateUrl: 'app/main/details.html',
            controller: 'MainDetailsCtrl'
          }
        },
        ncyBreadcrumb: {
          label: '{{medication.name}}'
        }
      }).state('main.detail.edit', {
        url: '/edit',
        views: {
          "@" : {
            templateUrl: 'app/main/edit/medication_form.html',
            controller: 'EditCtrl'
          }
        },
        ncyBreadcrumb: {
          label: 'Edycja'
        }
      });
  });

edit.controller.js

angular.module('aidkitApp')
.controller('EditCtrl', function ($scope, $http, $stateParams, $state) {
 ........
    $scope.save = function() {
        $http.put('/api/medications/'+$scope.model._id,$scope.model)
        .success(function(medication) {
            $state.go('^');
        });
    }
}

链接到启动main.details.edit

ui-sref=".edit"

保存,一切正常

这里是github repo的链接 https://github.com/mateutek/aidkit-fullstack

0 个答案:

没有答案
相关问题