Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.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
Javascript 烬嵌套管线和模型不渲染(根本不渲染)_Javascript_Ember.js_Handlebars.js - Fatal编程技术网

Javascript 烬嵌套管线和模型不渲染(根本不渲染)

Javascript 烬嵌套管线和模型不渲染(根本不渲染),javascript,ember.js,handlebars.js,Javascript,Ember.js,Handlebars.js,我可以获得要渲染的“帮助主题”标题,但没有我定义的装置。{{{#each model}}中的任何内容都不会呈现。这是我第一次使用Ember,所以任何东西(字面上的任何东西)都会有帮助,因为我在浏览器调试器中没有收到任何错误消息 App.js App.Router.map(function () { this.resource('home', { path: "/Index" }); this.resource('agents', { path: "/Agents" });

我可以获得要渲染的“帮助主题”标题,但没有我定义的
装置。
{{{#each model}}
中的任何内容都不会呈现。这是我第一次使用Ember,所以任何东西(字面上的任何东西)都会有帮助,因为我在浏览器调试器中没有收到任何错误消息

App.js

App.Router.map(function () {
    this.resource('home', { path: "/Index" });
    this.resource('agents', { path: "/Agents" });
    this.resource('topics',  function() {
        this.resource('topic', {path: '/topic/:topic_id'})
    });  
    this.resource('contacts', { path: "/Contacts" });
});

App.TopicRoute = Ember.Route.extend({
    model: function () {
        return App.Topic.find();
    }
})

App.Topic = DS.Model.extend({
    title: DS.attr('string'),
    info: DS.attr('string')
});

App.Topic.FIXTURES = [{
    id: 1,
    title: "Periscope",
    info: "Periscope is a read-only application pulling information from D3."
}, {
    id: 2,
    title: "Second post",
    info: "ASP.NET MVC 4 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of ASP.NET and the .NET Framework."
}, {
    id: 3,
    title: "Ember.js",
    info: "Ember.js is designed to help developers build ambitiously large web applications that are competitive with native apps."
}];
查看

                    <script type="text/x-handlebars">
                        <div class="navbar">
                            <div class="navbar-inner">                                
                            <ul id="menu">
                                <li>{{#linkTo 'home'}}Home{{/linkTo}}</li>
                                <li>{{#linkTo 'agents'}}Agents{{/linkTo}}</li>
                                <li>{{#linkTo 'topics'}}About{{/linkTo}}</li>
                                <li>{{#linkTo 'contacts'}}Contact{{/linkTo}}</li>
                            </ul>
                            </div>
                        </div>
                        {{outlet}}
                    </script>


<script type="text/x-handlebars" id="topics">
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span3">
                <table class='table'>
                <thead>
                    <tr><th>Help Topics</th></tr>
                </thead>
                {{#each model}}
                <tr><td>
                    {{#linkTo 'topic' this}}{{title}} {{/linkTo}}
                </td></tr>
                {{/each}}
                </table>
            </div>
            <div class="span9">
                {{outlet}}
            </div>
        </div>
    </div>
</script>
<script type="text/x-handlebars" id="topic">
    <h1>{{title}}</h1>

    <div class="intro">
        {{info}}
    </div>
</script>

  • {{{#链接到“home”}home{{/linkTo}
  • {{{#链接到“代理”}代理{{/linkTo}
  • {{{#链接到“主题”}关于{{/linkTo}
  • {{{#链接到“联系人”}联系人{{/linkTo}
{{outlet}} 帮助主题 {{{#每个模型} {{{#链接到“主题”这个}{{{title}}{{/linkTo}} {{/每个}} {{outlet}} {{title}} {{info}}
尝试如下更改路线:

App.TopicsRoute = Ember.Route.extend({
  model: function () {
    return App.Topic.find();
});

希望有帮助。

试着像这样改变你的路线:

App.TopicsRoute = Ember.Route.extend({
  model: function () {
    return App.Topic.find();
});

希望有帮助。

@NealR,欢迎你,总是乐于助人,如果答案可行,不要忘了将答案标记为已接受,这样未来的人就会知道它是正确的答案。@NealR,欢迎你,总是乐于助人,如果答案可行,不要忘了将答案标记为已接受,这样未来的人就会知道它是正确的答案。