【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 ...
随机推荐
- CSS 基础 优先级 选择器 继承
1.样式优先级 (内联样式)Inline style > (内部样式)Internal style sheet > (外部样式)External style ...
- activemq生产者和消费者的双向通信
http://websystique.com/spring/spring-4-jms-activemq-example-with-jmslistener-enablejms/
- Python自动化开发 - 字符串, 列表, 元组, 字典和和文件操作
一.字符串 特性:字符串本身不可修改,除非字符串变量重新赋值.Python3中所有字符串都是Unicode字符串,支持中文. >>> name = "Jonathan&q ...
- python- 动态加载目录下所有的类
# 背景 自动化测试框架中model层下有很多类,用来操作mysql的,使用的时候需要把全部的类加载进来,需要使用到动态加载类 # 解决方法 使用pkgutil,内置的方法,常用的话有两个方法 ite ...
- 查询字段描述sql-postgresql
查询字段描述sql SELECT 'comment on column ' || n.nspname ||'.'|| c.relname || '.' || a.attname ||' is '''| ...
- iOS-项目开发1-UIImage
UIImage+Extension /// 获取后的数据 a.length > b.length. 同时,使用UIIMageJPEGRepresnetation压缩图片,如果compressio ...
- raspberry pi wifi
vim /etc/network/interfaces 修改 wpa-ssid 和 wpa-psk
- Java - 集成开发环境Eclipse的使用方法和技巧
00 - Eclipse教程 Eclipse 教程 01 - Eclipse设置编译和运行的环境 建议编译和运行的版本保持一致,否则请特别注意: 低编译,高运行 ---> 可行. 高编译,低运行 ...
- Linux - APT包管理
dpkg与apt dpkg用来安装本地deb格式软件包,但不会解决软件包的依赖关系. APT(Advanced Packaging Tool)是从更新源获取并安装软件包,而且会解决依赖关系, 但不会安 ...
- python3 调用 salt-api
使用python3调用 salt-api 在项目中我们不能使用命令行的模式去调用salt-api,所以我们可以写一个基于salt-api的类,方便项目代码的调用.在这里特别附上两种方式实现的pytho ...