簡體   English   中英

ui-view不使用ng-boilerplate渲染

[英]ui-view does not render with ng-boilerplate

我在我的angular.js應用程序中使用ng-boilerplate和ui-router。 我有一個3節布局,一個頂欄,一個側欄和一個主布局。 我使用ng-switch在主布局中顯示不同的視圖。 這是我的index.html的樣子

<div class="slide-animate" ng-include="HeaderTemplate"></div>
<div class="slide-animate" ng-include="SidebarTemplate"></div>
<div ng-switch on="section">
     <div ui-view="secion1" class="secion1" ng-switch-when="secion1"></div>
     <div ui-view="secion2" class="secion2" ng-switch-when="secion2"></div>
     <div ui-view="secion3" class="secion3" ng-switch-when="secion3"></div>
</div>

我的HeaderTemplateSidebarTemplate正在呈現,但主布局未呈現。

我檢查了$scopesection的值。 這是section1 ,很好,當我在開發人員工具中檢查時,這就是DOM樣子

<div ng-switch="" on="section">
                <!-- ngSwitchWhen: section1 --><div ui-view="section1" class="section1 ng-scope" ng-switch-when="section1"><!-- ui-view-anchor --></div>
                <!-- ngSwitchWhen: section2 -->
                <!-- ngSwitchWhen: section3 -->
            </div>

因此,這里選擇了正確的部分,但ui-view僅顯示了注釋的ui-view-anchor (我不知道那是什么)。 我看了看我的html源,看我是否正在獲取我的section1section2等的模板,並且看到自己正在獲取它們。 我在templates-app.js看到了,我正在獲取我的部分的html。 知道為什么它獲取時不呈現html嗎? 我的$stateProvider配置看起來像這樣

$stateProvider.state('section1', {
            url: '/section1',
            views: {
                "section1": {
                    controller: 'Section1Ctrl',
                    templateUrl: 'section1/section1.tpl.html'
                }
            },
            data: { pageTitle: 'Section 1' }
        });

等等。

看來ui-router v0.2.8已損壞或與angular.js v1.2.12不兼容。 我切換回ui-router v0.2.7一切正常

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM