search

Home  >  Q&A  >  body text

angular.js - How to implement nested layout in angularjs?

That’s it. My application is divided into frontend (home) and user backend (user). According to the basic tutorial index.html is used as the homepage and also as the global layout.

The general structure of my project is as follows:

app
    app.js
    routes.js
    views
        home
            about
                index.html
            login
                index.html
            layout.html
        user
            dashboard
                index.html
            articles
                index.html
                detail.html
            layout.html
    index.html

What I think now is that the templates under views/home inherit views/home/layout.html, and the same applies to views/user.
Taking views/home/about/index.html as an example, the routing url is like this:

$routerProvider.when("/about",{
    templateUrl : "views/home/about/index.html"
});

The problem now is that app/views/home/about/index.html directly inherits app/index.html, and I want it to inherit like this:

app/views/home/about/index.html -> app/views/home/layout.html -> app/index.html -> Output to browser

How to achieve it?

======
I found a third-party plug-in called angular-ui-router, which can replace angular-router and can achieve this function.

習慣沉默習慣沉默2774 days ago623

reply all(3)I'll reply

  • 某草草

    某草草2017-05-15 16:53:01

    Your choice is right.

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-15 16:53:01

    It looks very similar to the structure of MEAN.JS, you can refer to it.

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-15 16:53:01

    Make all elements in the page into directives, put inheritance and nesting relationships in directives, and use several directives in combination on one page.

    reply
    0
  • Cancelreply