【angular5项目积累总结】侧栏菜单 navmenu
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的更多相关文章
- 多种css3时尚侧栏菜单展开显示效果Off-Canvas Menu Effects
今天我们想分享多种css3时尚侧栏菜单展开显示效果.侧边栏应用广泛,我们之前已经产生了一些效果灵感.风格演变,今天我们要展示一套新的灵感的现代效果.不同的布局和菜单的同步转换和页面可以让一切看起来更有 ...
- ionic 侧栏菜单用法
第一步: 引入js和css文件我这里是直接引入的cdn,ionic是基于angular的,bundle.min.js把常用angular的js已经压缩到一起,可以直接引入.bundle.min.js, ...
- Ionic Js十七:侧栏菜单
一个容器元素包含侧边菜单和主要内容.通过把主要内容区域从一边拖动到另一边,来让左侧或右侧的侧栏菜单进行切换. 效果图如下所示:   用法 要使用侧栏菜单,添加一个父元素,一个中间内容 ,和一个或更 ...
- ionic js 侧栏菜单 把主要内容区域从一边拖动到另一边,来让左侧或右侧的侧栏菜单进行切换
ionic 侧栏菜单 一个容器元素包含侧边菜单和主要内容.通过把主要内容区域从一边拖动到另一边,来让左侧或右侧的侧栏菜单进行切换. 效果图如下所示: 用法 要使用侧栏菜单,添加一个父元素<ion ...
- 【angular5项目积累总结】遇到的一些问题以及解决办法
1.项目中字符串特别是\r\n,替换成br之后,在页面换行无法生效? 答:绑定元素 innerHTML. <div class="panel-body" [innerHTML ...
- 【angular5项目积累总结】消息订阅服务
code import { Injectable } from '@angular/core'; import { Subject } from 'rxjs/Subject'; @Injectable ...
- 【angular5项目积累总结】列表多选样式框(2)
view code list.css :host { display: flex; width: 100%; border-left: 1px solid #ccc; font: normal 12p ...
- 【angular5项目积累总结】列表多选样式框(1)
憋不住想说一下:angular坑太多,各种教程各种不完整,官网还只是简单的画饼充饥,没办法只有自己研究自己总结,便于以后提高工作效率. 第一种: view code list.css :ho ...
- 【angular5项目积累总结】avatar组件
View Code import { Component, HostListener, ElementRef } from '@angular/core'; import { Adal4Service ...
随机推荐
- DevExpress控件汉化教程详解
所有Developer Express .NET产品都有本地化资源,比如按钮属性,控件属性描述,菜单项,确认和错误的信息等等,所有这些资源字符串可以很容易地被翻译成各种语言. 先看下面汉化前后的图片: ...
- Java框架知识点总结
一.Struts1的运行原理 在启动时通过前端总控制器ActionServlet加载struts-config.xml并进行解析,当用户在jsp页面发送请求被struts1的核心控制器ActionSe ...
- 数独 php
数独求解程序 php版 转载请注明出处:http://xiezhenye.com/2008/06/%e6%95%b0%e7%8b%ac%e6%b1%82%e8%a7%a3%e7%a8%8b%e5% ...
- 跨 iframe 传输数据
背景:项目用 easyUI 写前端,窗口使用 easyui-window 内嵌套 iframe 展示页面.遇到需要在窗口间传输数据的需求. 解决方案 获取 iframe 对象,然后通过获取的 ifra ...
- C#基础复习(4) 之 浅析List、Dictionary
参考资料 [1] .netCore 源码 https://github.com/dotnet/corefx [2] <Unity 3D脚本编程 使用C#语言开发跨平台游戏>陈嘉栋著 [3] ...
- .net core 与ELK(3)安装Kibana
1.去产品官网下载https://www.elastic.co/downloads/kibana 对应的tar.gz的压缩包,放到/usr/local/src目录 2.解压 -linux-x86_64 ...
- eclipse代码提示javadoc背景为黑色框的解决办法
我的eclipse是近期下载的oxygen版本.不知道怎么出现了一个这个问题,鼠标悬停指向代码时应该出现的代码提示解释框,全为黑色,看不到文字.如下图 经过验证,最终解决方法为window->G ...
- [NOIP2018]赛道修建(二分+multiset)
考场上打了一个 \(vector\) 解法,因为我当时不会 \(multiset\) 好吧,我来讲一讲今年的 \(tgD1T3\) 首先,这题 \(55\) 分是不难想的 1. \(b_i=a_i+1 ...
- CS231-Multi-calss SVM的求导
接着上周的更,上周我们更到,在对图像的线性分类中,我们只用multi-class 的svm,然后我们得到以下的损失函数 这里每个数值代表为下: X 是一个 N by D 的矩阵,N 代表 traini ...
- JS关闭窗口或JS关闭页面的几种代码!
第一种:JS定时自动关闭窗口 <script language="javascript"> <!-- function closewin(){ self.open ...