Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 仅为一条路线清除整个页面的内容_Ember.js_Ember Router - Fatal编程技术网

Ember.js 仅为一条路线清除整个页面的内容

Ember.js 仅为一条路线清除整个页面的内容,ember.js,ember-router,Ember.js,Ember Router,我使用以下概念构建了一个ember应用程序 <script type="text/x-handlebars"> <h2>Welcome to Ember.js</h2> {{outlet}} </script> 欢迎来到Ember.js {{outlet}} 所以,在每一条路线中,出口都将通过模板的html放置。但现在我接到一个请求,要求再创建一条路线,该路线有完全不同的内容要显示,甚至需要从上面清除欢迎访问Ember.

我使用以下概念构建了一个ember应用程序

<script type="text/x-handlebars">
    <h2>Welcome to Ember.js</h2>

    {{outlet}}
  </script>

欢迎来到Ember.js
{{outlet}}

所以,在每一条路线中,出口都将通过模板的html放置。但现在我接到一个请求,要求再创建一条路线,该路线有完全不同的内容要显示,甚至需要从上面清除
欢迎访问Ember.js
。我怀疑我是否能直接做到这一点。但是我可以做一些调整使它工作吗?

你需要做嵌套路由。 比如

这是指资源(“产品”)

假设在产品模板上,您必须{[outlet}}产品模板。 这让你有可能以不同的方式操纵hbs.ses。比如说,在产品模板中的产品旁边有一个列表

> 
>script type='text/x-handlebars' data-template-name='product' >

      {{title}}
    <p>{{description}}</p>
 <p>Buy for ${{price}}</p> </script>



<script type='text/x-handlebars' data-template-name='products'>
{{#each}}
{{#link-to 'product' this classNames='list-group-item'}}
{{title}}
{{/link-to}}
{{/each}}   
{{outlet}}
</script>
>
>脚本类型='text/x-handlebar'数据模板名称='product'>
{{title}}
{{description}}

以${{price}}购买

{{{#各} {{#链接到'product'这个classNames='list-group-item'} {{title}} {{/链接到} {{/每个}} {{outlet}}
App.Router.map(函数(){
this.resource(“header”,function()){
这是资源(“正常路由1”);
这是资源(“正常路由2”);
...
});
本资源(“特殊路线”);
});
欢迎来到Ember.js
{{outlet}}

这样构造项目,并在不希望出现标题的情况下使用“specialroute”。

我知道嵌套路由。但为此,我必须编辑所有位置的代码。我只是在寻找一种不会发生这种情况的解决方法。
> 
>script type='text/x-handlebars' data-template-name='product' >

      {{title}}
    <p>{{description}}</p>
 <p>Buy for ${{price}}</p> </script>



<script type='text/x-handlebars' data-template-name='products'>
{{#each}}
{{#link-to 'product' this classNames='list-group-item'}}
{{title}}
{{/link-to}}
{{/each}}   
{{outlet}}
</script>
App.Router.map(function(){
    this.resource("header", function(){
        this.resource("normalroute1");
        this.resource("normalroute2");
        ...
    });
    this.resource("specialroute");
});


<script data-template-name='header' type="text/x-handlebars">
    <h2>Welcome to Ember.js</h2>
    {{outlet}}
</script>