AngularJs Include Partial Template

前端 未结 2 1884
悲哀的现实
悲哀的现实 2020-12-04 21:26

I\'ve this in my main layout file


    
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 21:35

    From Angular 2, ngInclude has been removed and custom directives are preferred. This is the way I come up with

    1. Define the main component for your app, which link to the master page

          @View({
              templateUrl:   'client/app/layout/main.html',
              directives: [ROUTER_DIRECTIVES, Navigation, Footer]
          })
          @Component({selector: 'app'})
          @RouteConfig(
              routerConfig
          )
          class MainComponent {
          }
      

    And this is the main template

    
    
    
    
    
    
    
    
    
    
    
    1. Define a base.html, which will contain the body tag and the app tag

    Loading ...

    1. Now, final step is defining the components for Navigation and Footer like the MainComponent, which point to your partial templates

提交回复
热议问题