简体   繁体   English

热毛巾AngularJs子路线

[英]Hot Towel AngularJs Subroute

I am using Hot Towel AngularJs SPA that John Papa created. 我正在使用John Papa创建的Hot Towel AngularJs SPA。 I wanted to know how can I change the current menu to have sub menus. 我想知道如何将当前菜单更改为具有子菜单。

[Edited] The base implementation of HotTowel menu is looping into all routes and show it on the side bar. [编辑] HotTowel菜单的基本实现是循环进入所有路径,并将其显示在侧栏上。 What I wanted to do is if there are sub-menu for one of the routes then it's content will be grouped in one menu item. 我想做的是,如果其中一条路线有子菜单,那么它的内容将被分组在一个菜单项中。 similar to dropdowns sub menu 类似于下拉菜单

Don't forget that you're working with Models, and Controllers. 不要忘记您正在使用模型和控制器。

The Angular model and controller work in concert with the View John built. Angular模型和控制器与构建的View John协同工作。

public class HotTowelController : Controller
{
    //
    // GET: /HotTowel/

    public ActionResult Index()
    {
        return View();

Notice that the Index is the View. 请注意,索引是视图。

Ok. 好。

look at the url when you run the page. 在运行页面时查看网址。

name 名称

notice that its not loading another page. 请注意,它没有加载另一个页面。

That's because it's a SPA framework. 那是因为它是SPA框架。

The Index has a Javascript method where we are defining the roles outside of the .NET Framework / MVC 该索引具有Javascript方法,在该方法中我们定义.NET Framework / MVC之外的角色

So, we have a modeljs and a controllerjs. 因此,我们有一个modeljs和一个controllerjs。 Just like MVC we have to use all three. 就像MVC一样,我们必须同时使用这三个。 But use those in the APP folder. 但是,请使用APP文件夹中的内容。

The APP Folder APP文件夹

Admin Common dashboard layout services 管理员通用仪表板布局服务

viewmodels 的ViewModels

views 意见

etc... 等等...

So 所以

Go to the Layout Folder 转到布局文件夹

open topnav.html 打开topnav.html

THen read the viewmodels 阅读视图模型

shelljs shelljs

var routes = [
            { route: '', moduleId: 'home', title: 'Reserve a Seat', nav: 1 },
            { route: 'details', moduleId: 'details', title: 'Poker Details', nav: 2 }];

        return router.makeRelative({ moduleId: 'viewmodels' }) // router will look here for viewmodels by convention
            .map(routes)            // Map the routes
            .buildNavigationModel() // Finds all nav routes and readies them
            .activate();            // Activate the router
    }

Seee what's happening here. 看看这里发生了什么。 We are mapping, knockout and angular have very easy mappings. 我们在映射时,敲除和角度映射非常简单。

http://knockoutjs.com/documentation/plugins-mapping.html http://knockoutjs.com/documentation/plugins-mapping.html

This is an easy way to learn, and the vm is the smae for both only angular your using npm with a much more defined library in open source. 这是一种简单的学习方法,而vm是仅适用于使用npm和开放源代码中定义得多的库的smae。 both are mit so can't go wrong there. 两者都是麻省理工学院,所以不能出错。

then look at the config config.route mainjs 然后看一下config config.route mainjs

What do you see: Are you getting it? 您看到什么:明白了吗?

Need more? 需要更多?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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