【问题标题】:Is there a way to Create an intermidiate route in angular 2有没有办法在角度 2 中创建中间路线
【发布时间】:2017-09-29 17:43:22
【问题描述】:

我的目标是在每条其他导航路线中使用单个路由器插座和传统布局(页眉、正文、页脚)的单页面样式主页,并且在所有其他路线中使用一个路由器插座。 我不能只在主页中使用空的页眉和页脚组件的原因是因为我想将 fullpage.js 用于我的主页,并且它有非常严格的布局要求。 我希望有一个路由可以作为主页和应用程序其他部分的中间部分。并避免使用 /app(page:products) 等丑陋的网址

【问题讨论】:

    标签: angular angular2-routing


    【解决方案1】:

    你如何创建一个工厂,并使用 ng-content 使用角度转换。

    您的工厂示例:

      <div class="factory-container">
        <factory-header>
          <ng-content select="header"></ng-content>
        </factory-header>
        <div class="factory-section">
          <router-outlet></router-outlet>
        </div>
        <factory-footer>
          <ng-content select="footer"></ng-content>
        </factory-footer>
      </div>
    

    然后在你的一个组件内:

    <factory>
      <header>
       YOUR CONTENT LOGIC
      </header>
      <footer>
       YOUR CONTENT LOGIC
      </footer>
    </factory>
    

    也许这个链接会有所帮助:https://scotch.io/tutorials/angular-2-transclusion-using-ng-content

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-17
      • 2019-12-26
      • 2022-01-25
      • 2017-07-03
      • 1970-01-01
      • 1970-01-01
      • 2018-08-10
      • 2019-05-05
      相关资源
      最近更新 更多