angularjs中父子关系的关系

时间:2018-02-21 06:51:05

标签: angularjs ui-sref

我有一个关于父状态和子状态的问题。我有一个按钮。当我点击按钮时它会打开一个模态(状态:context.form)。它是okey但是我有另一个状态是调用new(新状态是context.form状态的子节点。。我想要做的是当我单击按钮父状态和子状态应该一起执行时。我认为问题是视图代码博客,因为相反观点我写另一个模态它正在工作

打开模态时,应在ui-view字段中显示子状态。 我的代码:

 .state('context.form', {
        parent: 'context',
        url: '/form',
        data: {
            authorities: ['ROLE_USER']
        },
        onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) {
            $uibModal.open({
                templateUrl: 'app/entities/context/contextForm.html',
                controller: 'ContextDialogController',
                controllerAs: 'vm',
                abstract: true,
                backdrop: 'static',
                windowClass: 'center-modal',
                size: 'md',
                resolve: {
                    entity: function () {
                        return {
                            name: null,
                            keywords: null,
                            createdAt: null,
                            status: null,
                            id: null
                        };
                    }
                }
            }) 
        }]
    })


      .state('new', {
            parent: 'context.form',
            url: ' ',
            data: {
                 authorities: ['ROLE_USER']
            },
            views: {
                'context.form@': {
                    templateUrl: 'app/entities/context/context-dialog2.html',
                    controller: 'ContextDialogController',
                    controllerAs: 'vm'
                }
            },

        })

contextForm.html     

<div class="" style="border-bottom:solid; border-bottom: solid;  height:25px;border-bottom-width: 1px;background-color: #337ab7">

    <button type="button" class="close" data-dismiss="modal" style="margin-right:30px; color:white; margin-top:2px"
        aria-hidden="true" ng-click="vm.clear()">&times;</button>
    <h4 class="modal-title" id="myContextLabel" style="margin-left:20px; color:white"
        data-translate="eventinsightwebApp.context.home.createOrEditLabel">Create
        New Alarm Watch</h4>
</div>

<div id="form-container" style="margin-top:30px">

    <!-- use ng-submit to catch the form submission and use our Angular function -->
    <form id="signup-form">

        <!-- our nested state views will be injected here -->
        <div id="form-views" ui-view></div>
    </form>



</div>

上下文dialog2.html

  <div class="form-group">
        <div class="col-md-1"><label data-translate="" style="margin-left:-8px" for="field_publicWatch">Public:</label></div>
    </div>

0 个答案:

没有答案
相关问题