Angular2 - 如何在模板中引用图像

时间:2016-09-12 07:38:46

标签: angular dart

我有这个结构:

enter image description here

我想参考" logo.svg"在我的组件中。 像这样:

public class ConnectAccept
{

    private static final int PORT = 46583;
    private static CountDownLatch latch = new CountDownLatch(1);

    public static void runClient() throws Exception
    {
        latch.await();
        Socket socket = new Socket();
        System.out.println("Client: connecting...");
        long t0 = System.currentTimeMillis();
        socket.connect(new InetSocketAddress("127.0.0.1", PORT));
        long t1 = System.currentTimeMillis();
        System.out.println("Client: connected. Millis: " + (t1 - t0));
        socket.close();
    }

    public static void runServer() throws Exception
    {
        ServerSocket serverSocket = new ServerSocket(PORT);
        latch.countDown();
        System.out.println("Server: accepting...");
        long t0 = System.currentTimeMillis();
        serverSocket.accept();
        long t1 = System.currentTimeMillis();
        System.out.println("Server: accepted. Millis: " + (t1 - t0));
        serverSocket.close();
    }

    public static void main(String[] args) throws Exception
    {
        Thread thread = new Thread(new Runnable()
        {
            @Override
            public void run()
            {
                try
                {
                    runClient();
                }
                catch (Exception ex)
                {
                    ex.printStackTrace();
                }
            }
        });
        thread.start();

        runServer();
    }

}

我应该在@Component( selector: 'my-app', template: '<img src="logo.svg">') class AppComponent {} 属性中添加什么来正确引用徽标?是否有特定的方案可供使用?

1 个答案:

答案 0 :(得分:0)

对于Angular 5.0.0,您可以这样引用它:

@Component(
    selector: 'my-app',
    template: '<img src="packages/angular_app/logo.svg">')
class AppComponent {}

angular_app替换为在您的 pubspec.yaml 中定义的名称