In my project I have this Help/FAQ Dialog. I'm trying make
only selected information to display but not sure how to do that so I would be really appreciated if I can get any help or suggestion.
For example,
when the user selected Item 1 from expansion panel, The right columns will display only Item 1 information and hide the others.
<div mat-dialog-content class="dialog-container">
<div class="container-inside-dialog">
<div class="row">
<div class="column left" style="background-color:pink">
<mat-nav-list>
<mat-expansion-panel>
<mat-expansion-panel-header>
Header 1
</mat-expansion-panel-header>
<a mat-list-item routerLink>Item 1</a>
<a mat-list-item routerLink>Item 2</a>
<a mat-list-item routerLink>Item 3</a>
</mat-expansion-panel>
</mat-nav-list>
<mat-nav-list>
<mat-expansion-panel>
<mat-expansion-panel-header>
Header 2
</mat-expansion-panel-header>
<a mat-list-item routerLink>Item 4</a>
<a mat-list-item routerLink>Item 5</a>
</mat-expansion-panel>
</mat-nav-list>
</div>
<div class="column right" style="background-color:grey">
<!-- Show this only when Item 1 is selected -->
<h2>Item 1</h2>
<p>Some text for Item 1..</p>
<p>more text.......</p>
<!-- Show this only when Item 2 is selected -->
<h2>Item 2</h2>
<p>Some text for Item 2..</p>
<!-- Show this only when Item 3 is selected -->
<h2>Item 3</h2>
<p>Some text for Item 3..</p>
<!-- Show this only when Item 4 is selected -->
<h2>Item 4</h2>
<p>Some text for Item 4..</p>
<!-- Show this only when Item 5 is selected -->
<h2>Item 5</h2>
<p>Some text for Item 5..</p>
</div>
</div>
</div>
</div>
This is my stackblitz project https://stackblitz.com/edit/mat-expansion-panel-bn9uwv
Thank you
Do it in steps
1-detect click on each item u want to be clicked
2-identify each click separately
3-store each click index or number
4-using that number show only desired item
here is code
Component
import {Component} from '#angular/core';
/**
* #title Basic expansion panel
*/
#Component({
selector: 'expansion-overview-example',
templateUrl: 'expansion-overview-example.html',
styleUrls: ['expansion-overview-example.css'],
})
export class ExpansionOverviewExample {
panelOpenState = false;
clickedIndex = -1;
clicked(index:number){
this.clickedIndex = index;
console.log(index);
}
}
/** Copyright 2018 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license */
Template
<div mat-dialog-content class="dialog-container">
<div class="container-inside-dialog">
<div class="row">
<div class="column left" style="background-color:pink">
<mat-nav-list>
<mat-expansion-panel>
<mat-expansion-panel-header>
Header 1
</mat-expansion-panel-header>
<a mat-list-item routerLink (click)="clicked(1)">Item 1</a>
<a mat-list-item routerLink (click)="clicked(2)">Item 2</a>
<a mat-list-item routerLink (click)="clicked(3)" >Item 3</a>
</mat-expansion-panel>
</mat-nav-list>
<mat-nav-list>
<mat-expansion-panel>
<mat-expansion-panel-header>
Header 2
</mat-expansion-panel-header>
<a mat-list-item routerLink (click)="clicked(4)" >Item 4</a>
<a mat-list-item routerLink (click)="clicked(5)">Item 5</a>
</mat-expansion-panel>
</mat-nav-list>
</div>
<div class="column right" style="background-color:grey">
<!-- Show this only when Item 1 is selected -->
<ng-container *ngIf= "clickedIndex == -1 || clickedIndex ==1">
<h2>Item 1</h2>
<p>Some text for Item 1..</p>
<p>more text.......</p>
</ng-container>
<!-- Show this only when Item 2 is selected -->
<ng-container *ngIf= "clickedIndex == -1 || clickedIndex ==2">
<h2>Item 2</h2>
<p>Some text for Item 2..</p>
<p>more text.......</p>
</ng-container>
<!-- Show this only when Item 1 is selected -->
<ng-container *ngIf= "clickedIndex == -1 || clickedIndex ==3">
<h2>Item 3</h2>
<p>Some text for Item 3..</p>
<p>more text.......</p>
</ng-container>
<!-- Show this only when Item 1 is selected -->
<ng-container *ngIf= "clickedIndex == -1 || clickedIndex ==4">
<h2>Item 4</h2>
<p>Some text for Item 4..</p>
<p>more text.......</p>
</ng-container>
<!-- Show this only when Item 1 is selected -->
<ng-container *ngIf= "clickedIndex == -1 || clickedIndex ==5">
<h2>Item 5</h2>
<p>Some text for Item 5..</p>
<p>more text.......</p>
</ng-container>
</div>
</div>
</div>
<div fxLayout="row" fxLayoutAlign="center start">
<span style="flex-grow: 1;"></span>
<button mat-raised-button color="primary" mat-dialog-close [style.marginRight.px]="20"
matTooltip="Close Help">Close</button>
</div>
</div>
Related
I been trying to create a navbar with a submenu. The nav bar data is rendered successfully but the submenu is not working, I am very new to this. Please let me know where is the problem.
<mat-nav-list class="navigation relative">
<div *ngFor="let link of navLinks; let i=index" style="padding-bottom: 14px;">
<div class="card">
<mat-list-item appAccordionlinks routerLinkActive="active-link" (click)="onClick(link.name)">
<a mat-button [matMenuTriggerFor]="submenu" *ngIf="link?.submenu?.length > 0" appAccordiontoggle
class="relative main-active">
<mat-icon *ngIf="link.icon">{{link.icon}}</mat-icon>
<img class="menu-img" *ngIf="link.img" [src]="link.img" alt="">
<app-menu-icon *ngIf="link.img" [name]="'employee'"></app-menu-icon>
<span>{{link.name}}</span><span fxFlex></span>
</a>
<a *ngIf="!(link?.submenu?.length > 0)" [routerLink]="link.path" appAccordiontoggle
class="relative main-active" mat-ripple fxLayout="row">
<mat-icon *ngIf="link.icon">{{link.icon}}</mat-icon>
<app-menu-icon *ngIf="link.img" [name]="link.name" [color]="link.color"></app-menu-icon>
<!-- <img class="menu-img" *ngIf="link.img" [src]="link.img" alt=""> this is need to mark as comment -->
<span>{{link.name}}</span>
</a>
</mat-list-item>
</div>
</div>
</mat-nav-list>
<mat-menu #submenu>
<ng-container *ngFor="let sublink of link?.submenu">
<ng-container *ngIf="link?.submenu?.length > 0">
<button mat-menu-item>
<img class="menu-img" *ngIf="sublink.img" [src]="sublink.img">
<span>{{sublink.name}}</span>
</button>
</ng-container>
</ng-container>
</mat-menu>
The mat-menu element is out of the scope of link variable. You need to include it (mat-menu) in the div you are dynamically rendering the links, i.e. within link's scope:
<div *ngFor="let link of navLinks; let i = index"...>
<--! card html -->
<mat-menu #submenu>
<--! submenu child elements... -->
</mat-menu>
</div>
I have an angular app (v6.1) which uses angular flex & Angular flex-layout. I am using angular v6.1 to make use of the fragment scroll feature. My page has a toolbar, side navigation with links to fragments within page and a center content(see the picture below). My requirement is to have the toolbar and left nav fixed while the center content alone should scroll. Following is my app.component.html. with this html, the whole of the page scrolls and not just the center content. How can I achieve the desired behaviour?
app.component.html
<div fxLayout="column">
<div fxFlex="20%" fxFlexFill style="background-color: rgb(48, 138, 133); ">
<mat-toolbar color="primary">
<mat-toolbar-row fxLayoutGap="10px">
<a type="button" href="#one">Menu item #1</a>
<a type="button" href="#two">Menu item #2</a>
</mat-toolbar-row>
</mat-toolbar>
</div>
<div fxFlex="80%">
<div fxLayout="row" style="background-color: cadetblue">
<div fxFlex="20%" fxLayout="column" style="background-color: chocolate">
<a mat-button routerLink="./" routerLinkActive="active" fragment="one">Nav Link #1</a>
<a mat-button routerLink="./" routerLinkActive="active" fragment="two">Nav Link #2</a>
<a mat-button routerLink="./" routerLinkActive="active" fragment="three">Nav Link #3</a>
<a mat-button routerLink="./" routerLinkActive="active" fragment="four">Nav Link #4</a>
<a mat-button routerLink="./" routerLinkActive="active" fragment="five">Nav Link #5</a>
</div>
<div fxLayout="column" fxLayoutGap="100px" fxFlex="100%"
style="background-color: chartreuse;">
<p id="one">para 1</p>
<p id="two">para 2</p>
<p id="three">para 3</p>
<p id="four">para 4</p>
<p id="five">para 5</p>
<p id="six">para 6</p>
<p id="seven">para 7</p>
<p id="eight">para content 8</p>
</div>
</div>
</div>
</div>
Okay. There's a few things that you need to do to make this work.
First, you need to make sure your body has a height of 100%. Otherwise, whenever an element is given a height of 100%, it won't know "100% of what" and will just grow as much as it wants.
The next thing you want is adding this style in a few places: height: 100%; overflow: auto. This says "the element fills it's parent, and if the content grows any bigger, make the content scrollable". Specifically, add these styles to the two inner columns.
stackblitz with result
One of the Best way to do what you require is
By creating the sidenav and toolbar as a separate component and rendering child components in the body (the green area )
Just like
<header role="mast-head">
<div class="container-fluid">
//Your header will come here
</div>
</header>
<div class="side bar">
<ul>
<li routerLinkActive="active" [routerLink]="['/homepage/h']"><img src="" alt="" />Dashboard</li>
<li routerLinkActive="active" [routerLink]="['/homepage/dst']"><img src="" alt="" />A</li>
<li routerLinkActive="active" [routerLink]="['/homepage/j']"><img src="" alt="" />B </li>
</ul>
</div>
<div class="body">
<router-outlet >
</router-outlet>
</div>
I've been trying to get the data.login of the data item on which user has clicked the avatar image. The HTML code is below.
I tried everything i could on the web but couldn't make it work.
How to get the current data.login to the corresponding .TS file.
Code:
<ul *ngFor="let data of uarr" class="list-unstyled" >
<li>
<div class="col-sm-6 col-md-3">
<div class="thumbnail">
<a routerLink="/" >
<img class="github-avatar" src="{{data.avatar_url}}" >
</a>
<div class="caption">
<h3 class="text-center">{{ data.login }}</h3>
</div>
</div>
</div>
</li>
Thank You.
Use Click Event
<ul *ngFor="let data of uarr" class="list-unstyled" >
<li>
<div class="col-sm-6 col-md-3">
<div class="thumbnail" (click)="onClick(data.login)">
<a routerLink="/" >
<img class="github-avatar" src="{{data.avatar_url}}" >
</a>
<div class="caption">
<h3 class="text-center">{{ data.login }}</h3>
</div>
</div>
</div>
</li>
TS
onClick(login){
console.log(login);
}
I just want to remove the tittle bar (header) (blue side part in image)inside this page.
my ionic code in about.html page
<nav-page hide-nav-bar="true">
<ion-view>
<ion-content class="app-view">
<div class="list-inset-feed">
<div class="item item-text-wrap">
<div class="row responsive-sm text-center">
<div class="col">
<h1 class="text-white">{{"about_page_title" | translate}}</h1>
<h3 class ="text-white">version 1.0.0</h1>
<div class="image_container">
<img alt="logo" height="100" src="img/logo.png">
</div>
<a class="text-white" href="#" onclick="window.open('http://abcd.html', '_system', 'location=yes'); return false;">
privacy policy
</a>
</div>
</div>
</div>
</div>
</ion-content>
Add hide-nav-bar="true" inside your <ion-view> tag.
HTML
<ion-view hide-nav-bar="true">
<ion-content >
</ion-content>
</ion-view>
I'm trying to put header and top navbar inside of the ion-view directive.
If I put header nav navbar outside of the ion-view tag page is blinking black if page is initialized.
But if I try to insert header and top navbar inside of the ion-view title and heading in the header is not displayed.
Could somebody tell me what I'm doing wrong?
Maybe some tag inside is missing?
Thanks for any help.
Here is the code of the template:
<div class="bar bar-header bar-positive has-tabs-top">
<button class="button button-icon icon ion-chevron-left" ui-sref="home">
</button>
<h1 class="title">{{ 'RESULTS_BY_DAY' | translate }}</h1>
<button class="button button-icon icon ion-stats-bars" ui-sref="daily-chart">
</button>
</div>
<!--TOP TAB BAR -->
<div class="tabs-striped tabs-top tabs-background-light tabs-light tabs-color-dark">
<div class="tabs">
<a class="tab-item orange">
Home
</a>
<a class="tab-item">
Favorites
</a>
<a class="tab-item">
Settings
</a>
</div>
</div>
<ion-view>
<div class="bar bar-header bar-positive has-tabs-top">
<button class="button button-icon icon ion-chevron-left" ui-sref="home">
</button>
<h1 class="title">{{ 'RESULTS_BY_DAY' | translate }}</h1>
<button class="button button-icon icon ion-stats-bars" ui-sref="daily-chart">
</button>
</div>
<!--TOP TAB BAR -->
<div class="tabs-striped tabs-top tabs-background-light tabs-light tabs-color-dark">
<div class="tabs">
<a class="tab-item orange">
Home
</a>
<a class="tab-item">
Favorites
</a>
<a class="tab-item">
Settings
</a>
</div>
</div>
<ion-content ng-controller="DailyListCtrl">
<!--WRITEOUT OVERAL STATS FOR DAYS -->
<ion-list class="list" >
<ion-item class="item itemListCustom" ng-repeat="listDataItem in listData">
<div class="listDateTimeBlock">
<div class="day"><h3>{{listDataItem.DATE_FROM_DD}}</h3></div>
<div class="month"><h3>{{listDataItem.DATE_FROM_MM}}</h3></div>
</div>
<!--ROW ONE -->
<div id="left">
<div class="left-inner">
{{ 'APPOINTMENT_SUCCESS_RATE' | translate }}:
</div>
<div class="right-inner">
{{listDataItem.SUCCESS_RATE}} %
</div>
</div>
<div id="right">
<div class="left-inner floatRight">
{{ 'DIALS' | translate }}:
</div>
<div class="right-inner">
{{listDataItem.DIALS_CNT}}
</div>
</div>
<!--ROW TWO-->
<div id="left">
<div class="left-inner ">
{{ 'SUCCESS_RATE_SINCE_START' | translate }}:
</div>
<div class="right-inner">
{{listDataItem.SUCCESS_RATE_SINCE}} %
</div>
</div>
<div id="right">
<div class="left-inner floatRight">
{{ 'CONVERSATIONS' | translate }} :
</div>
<div class="right-inner">
{{listDataItem.CONVERS_CNT}}
</div>
</div>
<!--ROW THREE-->
<div id="left">
<div class="left-inner">
{{ 'MY_DEFICIT' | translate }}:
</div>
<div class="right-inner">
{{listDataItem.DEFICIT}} %
</div>
</div>
<div id="right">
<div class="left-inner floatRight">
{{ 'APPOINTMENTS' | translate }} :
</div>
<div class="right-inner">
{{listDataItem.APPT_CNT}}
</div>
</div>
</ion-item>
</ion-list>
<ion-infinite-scroll
icon="ion-loading-c"
distance="30%"
on-infinite="setDateRange();">
</ion-infinite-scroll>
</ion-content>
<!-- BOTTOM TABS -->
<div class="tabs-striped tabs-background-positive tabs-light">
<div class="tabs">
<a class="tab-item active" ui-sref="daily-list" href="/#/daily-list">
<i class="icon ion-ios7-paper-outline"></i>
</a>
<a class="tab-item" ui-sref="weekly-list" href="/#/weekly-list">
<i class="icon ion-star"></i>
</a>
<a class="tab-item" ui-sref="daily-list" href="/#/daily-list">
<i class="icon ion-gear-a"></i>
</a>
<a class="tab-item" ui-sref="daily-list" href="/#/daily-list">
<i class="icon ion-gear-a"></i>
</a>
</div>
</div>
</ion-view>
Here are some examples of navbar usage:
Simple page with buttons left and right:
http://codepen.io/beaver71/pen/YwLELa
<ion-view title="onepage">
<ion-nav-buttons side="left">
<button class="button">
LeftButton
</button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button class="button button-assertive">
RightButton
</button>
</ion-nav-buttons>
<ion-content class="padding">
<!-- The content of the page -->
</ion-content>
</ion-view>
Navigation via side menu:
http://codepen.io/beaver71/pen/XXBvYp
Navigation via side menu and tab bar:
http://codepen.io/beaver71/pen/xZWXBO
Try to use the JavaScript versions of tabs and navigation bars.
They are easier to be manipulated in JS code, because they come with the services $ionicTabsDelegate and $ionicNavBarDelegate.