View

Code

import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ConfigureService } from '../../configure/configure.service';
import { Router } from '@angular/router'; @Component({
selector: 'nav-menu',
templateUrl: './navmenu.component.html',
styleUrls: ['./navmenu.component.css'],
host: {
'class': 'fxs-sidebar fxs-trim-border',
'[class.fxs-sidebar-is-collapsed]': '!sidebarExpanded'
}
})
export class NavMenuComponent implements OnInit {
constructor(private httpProvider: HttpClient,
public configService: ConfigureService,
private router: Router
) { } create() {
this.router.navigate(['/create'], {});
} isExpanded: boolean = true; sidebarExpanded: boolean = true; menuItems: Array<any> = []; sideMenu: any; _toggleSidebar(): void {
this.sidebarExpanded = !this.sidebarExpanded;
} isHyperLink(path): boolean {
if (path.indexOf('http') == 0) {
return true;
}
return false;
} showSideMenu(): boolean {
return this.sideMenu != null;
} ngOnInit(): void {
let setting = this.configService.config; if (this.menuItems.length == 0) {
this.httpProvider
.get(setting.PlatformServer + setting.Api_menus)
.subscribe((result: any) => {
this.menuItems = result;
for (var i = 0; i < this.menuItems.length; i++) {
if (this.menuItems[i].link == 'SideMenu') {
this.sideMenu = this.menuItems[i];
return;
}
}
});
}
}
}
<div class="fxs-sidebar-bar fxs-trim fxs-trim-text">
<div class="fxs-sidebar-top">
<button class="expanderBtn fxs-sidebar-collapse-button fxs-trim-hover fxs-trim-svg" title="Show text labels" (click)="_toggleSidebar()">
<svg height="100%" width="100%" role="presentation" focusable="false">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#FxSymbol0-00f"></use>
</svg>
</button>
<!--<button class="fxs-sidebar-create fxs-trim-hover fxs-trim-border" role="button" title="新建" (click)="create()">
<div class="fxs-sidebar-button-flex">
<div class="fxs-sidebar-create-icon fxs-fill-success">
<svg viewBox="0 0 18 18" class="" role="presentation" focusable="false" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="FxSymbol0-00f" width="100%" height="100%"><g><title></title><path d="M8 18h2v-8h8V8h-8V0H8v8H0v2h8z"></path></g></svg>
</div>
<div class="fxs-sidebar-create-label fxs-sidebar-show-if-expanded fxs-trim-text">新建</div>
</div>
<span class="fxs-hide-accessible-label">新建</span>
</button>-->
</div>
<div class="fxs-sidebar-middle" role="navigation">
<ul class="fxs-sidebar-favorites">
<ng-container *ngFor="let menuItem of menuItems">
<li *ngIf="menuItem.link != 'SideMenu'" class="fxs-sidebar-item fxs-trim-hover fxs-sidebar-draggable fxs-sidebar-droppable fxs-trim-border" draggable="true" attr.aria-label="{{menuItem.menuName}}">
<a *ngIf="isHyperLink(menuItem.link);then hyperlink else routerlink"></a>
<ng-template #routerlink>
<a routerLink={{menuItem.link}} class="fxs-sidebar-item-link fxs-trim-text" title="{{menuItem.menuName}}" role="link">
<div class="fxs-sidebar-icon fxs-trim-svg">
<svg height="100%" width="100%" role="presentation" focusable="false">
<use xmlns:xlink="http://www.w3.org/1999/xlink" attr.xlink:href="{{menuItem.icon}}"></use>
</svg>
</div>
<div class="fxs-sidebar-label fxs-sidebar-show-if-expanded" *ngIf="isExpanded">{{menuItem.menuName}}</div> </a>
</ng-template>
<ng-template #hyperlink>
<a href={{menuItem.link}} target="_blank" class="fxs-sidebar-item-link fxs-trim-text" title="{{menuItem.menuName}}" role="link">
<div class="fxs-sidebar-icon fxs-trim-svg">
<svg height="100%" width="100%" role="presentation" focusable="false">
<use xmlns:xlink="http://www.w3.org/1999/xlink" attr.xlink:href="{{menuItem.icon}}"></use>
</svg>
</div>
<div class="fxs-sidebar-label fxs-sidebar-show-if-expanded" *ngIf="isExpanded">{{menuItem.menuName}}</div>
<div class="fxs-sidebar-icon fxs-trim-svg" style="padding-right:19px;">
<svg style="height:15px" viewBox="0 0 16 16" class="msportalfx-svg-palette-inherit" role="presentation" focusable="false" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="FxSymbol0-067" width="100%" height="100%"><g><title></title><path d="M4.992 9.819l8.018-7.991v4.005H14V0H8.167v1h4.038L4.232 8.987l.76.833z"></path><path d="M12.993 13.03H1.01V1.028h4.823V0H0v14h14V8.167h-1.007v4.863z"></path></g></svg>
</div>
</a>
</ng-template>
</li>
</ng-container>
</ul>
</div>
<side-menu *ngIf="showSideMenu()" [SideMenuName]="sideMenu.menuName"></side-menu>
</div>

【angular5项目积累总结】侧栏菜单 navmenu的更多相关文章

  1. 多种css3时尚侧栏菜单展开显示效果Off-Canvas Menu Effects

    今天我们想分享多种css3时尚侧栏菜单展开显示效果.侧边栏应用广泛,我们之前已经产生了一些效果灵感.风格演变,今天我们要展示一套新的灵感的现代效果.不同的布局和菜单的同步转换和页面可以让一切看起来更有 ...

  2. ionic 侧栏菜单用法

    第一步: 引入js和css文件我这里是直接引入的cdn,ionic是基于angular的,bundle.min.js把常用angular的js已经压缩到一起,可以直接引入.bundle.min.js, ...

  3. Ionic Js十七:侧栏菜单

    一个容器元素包含侧边菜单和主要内容.通过把主要内容区域从一边拖动到另一边,来让左侧或右侧的侧栏菜单进行切换. 效果图如下所示:   用法 要使用侧栏菜单,添加一个父元素,一个中间内容 ,和一个或更 ...

  4. ionic js 侧栏菜单 把主要内容区域从一边拖动到另一边,来让左侧或右侧的侧栏菜单进行切换

    ionic 侧栏菜单 一个容器元素包含侧边菜单和主要内容.通过把主要内容区域从一边拖动到另一边,来让左侧或右侧的侧栏菜单进行切换. 效果图如下所示: 用法 要使用侧栏菜单,添加一个父元素<ion ...

  5. 【angular5项目积累总结】遇到的一些问题以及解决办法

    1.项目中字符串特别是\r\n,替换成br之后,在页面换行无法生效? 答:绑定元素 innerHTML. <div class="panel-body" [innerHTML ...

  6. 【angular5项目积累总结】消息订阅服务

    code import { Injectable } from '@angular/core'; import { Subject } from 'rxjs/Subject'; @Injectable ...

  7. 【angular5项目积累总结】列表多选样式框(2)

    view code list.css :host { display: flex; width: 100%; border-left: 1px solid #ccc; font: normal 12p ...

  8. 【angular5项目积累总结】列表多选样式框(1)

    憋不住想说一下:angular坑太多,各种教程各种不完整,官网还只是简单的画饼充饥,没办法只有自己研究自己总结,便于以后提高工作效率. 第一种: view      code list.css :ho ...

  9. 【angular5项目积累总结】avatar组件

    View Code import { Component, HostListener, ElementRef } from '@angular/core'; import { Adal4Service ...

随机推荐

  1. unigui编译路径设置

    unigui编译路径设置 先设路径变量 再追加如下路径,即可成功编译: ;$(uni)\uniTools\Dcu\Delphi2021;$(uni)\uniGUI\Dcu\Delphi2021;$(u ...

  2. Centos 7 安装 PostgreSQL PGAdmin4

    本文只讲PostgreSQL在CentOS 7.x 下的安装,其他系统请查看:https://www.postgresql.org/download PostgreSQL 所用版本为:PostgreS ...

  3. WPF 打印界面(控件)到A4纸

    这次遇到一个需求,就是将整个界面打印在A4纸上. 需求清楚后,Bing一下关于打印,就找到一个类PrintDialog ,其中两个方法可能会用到: 特别是public void PrintVisual ...

  4. EF学习笔记-2 EF之支持复杂类型的实现

    使用过.NET的小伙伴们知道,在我们的实体模型中,除了一些简单模型外,还有一些复杂类型,如几个简单的类型组合而成的类型:而EF除了在实现基本的增删改查之外,也支持复杂类型的实现. 那么如何手动构造复杂 ...

  5. .net下WinDbg使用说明

    加载调试文件 .loadby sos mscorwks #.Net 3.5版本及以下 .loadby sos clr #.Net 4.0 WinDbg的基本命令 !threads #显示所有线程 !d ...

  6. 【转】C#中dynamic的正确用法

    原文:http://www.cnblogs.com/qiuweiguo/archive/2011/08/03/2125982.html dynamic是FrameWork4.0的新特性.dynamic ...

  7. Spring AOP 源码分析 - 创建代理对象

    1.简介 在上一篇文章中,我分析了 Spring 是如何为目标 bean 筛选合适的通知器的.现在通知器选好了,接下来就要通过代理的方式将通知器(Advisor)所持有的通知(Advice)织入到 b ...

  8. C#6.0语言规范(十一) 结构

    结构与类类似,因为它们表示可以包含数据成员和函数成员的数据结构.但是,与类不同,结构是值类型,不需要堆分配.结构类型的变量直接包含结构的数据,而类类型的变量包含对数据的引用,后者称为对象. 结构对于具 ...

  9. ubuntu14中把openssh升级到7.5

    经验证可用 下载相关tar.gz包,没有下载到的,可以在这里下载.http://download.csdn.net/download/songanshu/10023663 apt install -y ...

  10. JS实现网页背景旋转缩放轮播效果

    实现效果:效果预览 css代码: .switch_images { display: inline-block; margin:; padding:; width: 100%; height: 100 ...