Angular2路由:无法找到外部html文件

时间:2016-02-26 18:49:35

标签: routes angular

在angular2中,如果在@component中使用内部模板,则路由有效。但是如果使用templateUrl添加外部模板,则会显示错误:无法找到资源** .html。如果使用外部模板,是否需要添加其他内容?

{% for item in data.Items %}
    <button onclick="$(this).siblings('div.extrainfo').toggle();">Person Name:   {{ item.name }}</button><br>
    <div class="extrainfo">
        Age:   {{ item.age }}<br>
        Height:   {{ item.height }}<br>
        Weight:   {{ item.weight }}<br>
    </div>
    <br><br>
{% endfor %}

1 个答案:

答案 0 :(得分:1)

做这样的事情:

templateUrl:"rootDir/Components/template.html"

我的猜测是你正在使用这样的相对路径。

templateUrl:"./template.html"

但是,如果没有看到更多的代码,很难找出确切的问题。

相关问题