javascript - 如何以 Angular 加载基本 html View 中的 View ?

标签 javascript jquery angularjs angularjs-directive angularjs-ng-repeat

我需要在基本 html 文件中加载两个 html 文件。换句话说,我有基本 html 文件,其中有标题和竞争 View 。我需要在标题和竞争 View 中加载不同的 HTML 文件。 这是基本 HTML 文件

<div class="container">

    <div class="row page-header">
        <ui-view name="header"></ui-view>
    </div>

    <ui-view name="content"></ui-view>

    <div class="row">
        <div class="col-xs-12">
            <hr>
            <p class="text-center">Test Come</p>
        </div>
    </div>
</div>

在此 View 中

  <ui-view name="header"></ui-view>

在 header 中我需要加载 header.html 和 <ui-view name="content"></ui-view>在此我需要加载 content.html http://plnkr.co/edit/nMhlb0R1q3BhWBHEjCks?p=preview 谢谢

最佳答案

您需要根据子状态更新您的状态:

var config = function($stateProvider,$urlRouterProvider) {
      $urlRouterProvider.otherwise('/');
       $stateProvider
       .state('main', {
        url: '/',
        views: {

            // the main template will be placed here (relatively named)
            '': { templateUrl: 'base.html' },


            // the child views will be defined here (absolutely named)
            'content@main': { template: 'contend.html' },

            // for column two, we'll define a separate controller 
            'header@main': { 
                templateUrl: 'header.html',

            }
        }

    });
};

关于javascript - 如何以 Angular 加载基本 html View 中的 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27895904/

相关文章:

angularjs - 有没有一种方法可以用 AngularJS 进行 ng-repeat 覆盖多个数组?

javascript - 如何让 AngularJS 在 svg 模板中填充初始标签值?

javascript - 如何在 TableTools 中使用链接而不是闪光按钮

javascript - Angular UI 路由器 : where should I be changing state? Controller ?服务?事件监听器?

php - jQuery 从 JSON 字符串创建 HTML

javascript - Bootstrap .container-fluid 溢出

jquery - 有没有更有效的方法来编写 $ ('parent > child' )?

javascript - 模块中定义的 js 函数可以在模块外部访问吗?

javascript - 从数组中的所有数字中提取一个数字

javascript - 我如何检查一个数组中的值是否在一个单独的数组中具有特征,如果存在,则在将它们各自转换为新值后返回这些值