简体   繁体   中英

value is not pass to partials files express handlebars cant find the error

I am asking this question again because i did not get any response on my previous question. i am trying to fetch the pages names from DB to sidebar but i can't. my sidebar in the partials folder.

what i have tried

    // controller
    
        index: (req, res) => {
                db.query("SELECT * FROM mp_pages", function (err, pages) {
                    return res.render('layouts/admin', { page: pages });
                })
            }, 


   

// here is the admin layout

    {{> header }}
    
    <body id="page-top">
    
        <!-- Page Wrapper -->
        <div id="wrapper">
    
            <!-- Sidebar -->
             {{#each pages}}
                {{> adminSidebar this}}
            {{/each}}
            {{!-- {{> adminSidebar pages}} --}}
    
    
            <!-- Cotent Wrapper -->
            <div id="content-wrapper" class="d-flex flex-column">
    
                <!-- Main Content -->
                <div id="content">
    
                    <!-- Topbar -->
                    {{> topbar}}
                    <!-- End of Topbar -->
    
                    <!-- Begin Page Content -->
                    <div class="container-fluid">
    
                        <!-- Page Heading -->
                        {{{ body }}}
                    </div>
                    <!-- /.container-fluid -->
    
                </div>
                <!-- End of Main Content -->
    
                <!-- Footer -->
                {{> footer }}

and this is my exact sidebar where i want to show the page title.

<!-- Nav Item - Dashboard -->
<li class="nav-item">
    <a class="nav-link" href="index.html">
        <i class="fas fa-fw fa-tachometer-alt"></i>
        <span>{{this}}</span></a>
</li>
<!-- End of Sidebar -->

  

what is the exact way pass the data from controller to partials ?

{{> header }}

<!-- Page Wrapper -->
<div id="wrapper">

    <!-- Sidebar -->

    {{> adminSidebar pages=pages}}

    {{!-- {{> adminSidebar pages}} --}}


    <!-- Cotent Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">

        <!-- Main Content -->
        <div id="content">

            <!-- Topbar -->
            {{> topbar}}
            <!-- End of Topbar -->

            <!-- Begin Page Content -->
            <div class="container-fluid">

                <!-- Page Heading -->
                {{{ body }}}
            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- End of Main Content -->

        <!-- Footer -->
        {{> footer }}





        <!-- Nav Item - Dashboard -->
        <li class="nav-item">
            {{#each pages}}

                <a class="nav-link" href="index.html">
                    <i class="fas fa-fw fa-tachometer-alt"></i>
                    <span>{{this}}</span>
                </a>

            {{/each}}
        </li>
        <!-- End of Sidebar -->

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM