binding the data from component in HTML page : Angular 6 - html

I'm new to angular 6 so please. I have my component.ts where i'm having my response. Now I want to bind data based on filter value in my HTML page. That is when the user clicks on the Owner Name. Now I want to display the owner name on the top right corner of my HTML page. How can I achieve that?
Here is how my HTML page looks like.
My component.ts page looks like this:
import { CampaignService } from './../../../services/campaign.service';
import { Component, OnInit, Input } from '#angular/core';
#Component({
selector: 'home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
constructor(private campaignService : CampaignService) { }
Time :any;
campaigns :any;
filter;
show:boolean = false ;
ngOnInit(){
setInterval(() => {
this.Time = Date.now()
}, 1000);
this.campaignService.CampaignsInfo()
.subscribe(response=>{
this.show = false;
this.campaigns = response;
});
}
filterByOwnr(val){
if(val != null)
{
this.show=true;
}
else
{
this.show=false;
}
this.filter = val;
}
}
and my HTML page looks like this:
<campaign-header></campaign-header>
<div class="container-fluid date-time sticky-top">
<div class="container">
<div class="d-flex justify-content-end" style="margin-top: -16px;">
<span id="date_time"><i class="zmdi zmdi-calendar-check zmdi-hc-fw"></i> {{Time | date}} <i class="zmdi zmdi-time zmdi-hc-fw"></i> {{ Time | date:'mediumTime' }} </span>
</div>
</div>
</div>
<br>
<!-- content -->
<div class="container">
<h3>Campaigns</h3>
<div class="clearfix"></div>
<div class="row">
<div class="col-sm-12">
<div class="card campaign border-top wrap mt-4">
<br>
<div class="card-body table-responsive">
<table class="table table-hover mb-0 ">
<thead>
<tr>
<th class="border-top-0">CAMPAIGN </th>
<th class="border-top-0">STATUS</th>
<th class="border-top-0">DIALED</th>
<th class="border-top-0">OWNERS</th>
<th class="border-top-0"> <span class="invisible">Action</span></th>
<th></th>
<!-- <button mat-button color="primary" routerLink="/campaign-details">CampaignDetails</button> -->
</tr>
</thead>
<tbody>
<tr *ngFor="let campaign of campaigns?.result | filter : 'OWNERS' : filter;">
<td style="max-width:280px">
<p>{{campaign.CampaignName}}</p>
<small>{{campaign.DepartmentName}}</small>
</td>
<td>
<small class="text-info">Active</small>
</td>
<td>
<p>{{campaign.Dialed}} / <small>1500000</small></p>
<div class="progress mt-2 w-75">
<div class="progress-bar bg-info" role="progressbar" style="width: 90%;" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</td>
<td>
<span class="badge badge-pill badge-secondary cursor" (click)="filterByOwnr(campaign.CampaignName)"> {{ campaign.CampaignName }} </span>
<a (click)="filterByOwnr()" *ngIf=show style="position: relative; left: -16px; top: -1px; color: #fff; font-size: 8px; border: 1px solid #fff; border-radius: 15px; font-weight: bold; cursor: pointer; "><i class="zmdi zmdi-close zmdi-hc-fw"></i> </a>
</td>
<td class="ml-0 pl-0">
<a [routerLink]="['/campaign-details' , campaign.Id]" [queryParams]="{ CampaignName : campaign.CampaignName , SubCampaign : campaign.SubCampaign, DepartmentName : campaign.DepartmentName }"><img src="../../assets/Images/next.png" class="next" /></a>
<a (click)="filterByOwnr()" *ngIf=show class="close_icon"><i class="zmdi zmdi-close zmdi-hc-fw"></i> </a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<br>
</div>

import { CampaignService } from './../../../services/campaign.service';
import { Component, OnInit, Input } from '#angular/core';
#Component({
selector: 'home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
constructor(private campaignService : CampaignService) { }
Time :any;
campaigns :any;
filter;
show:boolean = false ;
selectedOwner:string;
ngOnInit(){
setInterval(() => {
this.Time = Date.now()
}, 1000);
this.campaignService.CampaignsInfo()
.subscribe(response=>{
this.show = false;
this.campaigns = response;
});
}
filterByOwnr(val){
if(val != null)
{
this.selectedOwner = val;
this.show=true;
}
else
{
this.show=false;
}
this.filter = val;
}
}
<campaign-header></campaign-header>
<div class="container-fluid date-time sticky-top">
<div class="container">
<div class="d-flex justify-content-end" style="margin-top: -16px;">
<span id="date_time"><i class="zmdi zmdi-calendar-check zmdi-hc-fw"></i> {{Time | date}} <i class="zmdi zmdi-time zmdi-hc-fw"></i> {{ Time | date:'mediumTime' }} </span>
</div>
</div>
</div>
<br>
<!-- content -->
<div class="container">
<h3>Campaigns</h3>
<div class="clearfix"></div>
<div class="row">
<div class="col-sm-12">
<div class="card campaign border-top wrap mt-4">
<br>
<div class="card-body table-responsive">
<span class="badge badge-pill badge-secondary" *ngIf="selectedOwner && show"> {{selectedOwner}} </span> <a (click)="filterByOwnr()" *ngIf=show style="position: relative; left: -16px; top: -1px; color: #fff; font-size: 8px; border: 1px solid #fff; border-radius: 15px; font-weight: bold; cursor: pointer; "><i class="zmdi zmdi-close zmdi-hc-fw"></i> </a>{{selectedOwner}}</span>
<table class="table table-hover mb-0 ">
<thead>
<tr>
<th class="border-top-0">CAMPAIGN </th>
<th class="border-top-0">STATUS</th>
<th class="border-top-0">DIALED</th>
<th class="border-top-0">OWNERS</th>
<th class="border-top-0"> <span class="invisible">Action</span></th>
<th></th>
<!-- <button mat-button color="primary" routerLink="/campaign-details">CampaignDetails</button> -->
</tr>
</thead>
<tbody>
<tr *ngFor="let campaign of campaigns?.result | filter : 'OWNERS' : filter;">
<td style="max-width:280px">
<p>{{campaign.CampaignName}}</p>
<small>{{campaign.DepartmentName}}</small>
</td>
<td>
<small class="text-info">Active</small>
</td>
<td>
<p>{{campaign.Dialed}} / <small>1500000</small></p>
<div class="progress mt-2 w-75">
<div class="progress-bar bg-info" role="progressbar" style="width: 90%;" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</td>
<td>
<span class="badge badge-pill badge-secondary cursor" (click)="filterByOwnr(campaign.CampaignName)"> {{ campaign.CampaignName }} </span>
<a (click)="filterByOwnr()" *ngIf=show style="position: relative; left: -16px; top: -1px; color: #fff; font-size: 8px; border: 1px solid #fff; border-radius: 15px; font-weight: bold; cursor: pointer; "><i class="zmdi zmdi-close zmdi-hc-fw"></i> </a>
</td>
<td class="ml-0 pl-0">
<a [routerLink]="['/campaign-details' , campaign.Id]" [queryParams]="{ CampaignName : campaign.CampaignName , SubCampaign : campaign.SubCampaign, DepartmentName : campaign.DepartmentName }"><img src="../../assets/Images/next.png" class="next" /></a>
<a (click)="filterByOwnr()" *ngIf=show class="close_icon"><i class="zmdi zmdi-close zmdi-hc-fw"></i> </a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<br>
</div>
Here I am assuming you can only filter on one owner at a time, from the code that is what it looks like. If you can filter on multiple you would obviously have to store the selected in an array. Also not sure where you would be clearing the owner, but wherever you do that you then also would want to clear the selected owner string or array.

Initialize a class property which hold the selected owner name
public selectedOwnerName: string = '';
Make the owner's section as
<td>
<span class="badge badge-pill badge-secondary cursor" (click)="selectedOwnerName = campaign?.CampaignName"> {{ campaign?.CampaignName }}
<a *ngIf="selectedOwnerName == campaign?.CampaignName" style="position: relative; left: -16px; top: -1px; color: #fff; font-size: 8px; border: 1px solid #fff; border-radius: 15px; font-weight: bold; cursor: pointer; "><i class="zmdi zmdi-close zmdi-hc-fw"></i> </a>
</span>
</td>
No need to use a filterByOwnr() method to set values, you can set the value to the class property directly on the click. Use the class property {{selectedOwnerName}} (find the appropriate place to place this elem) in your HTML to display the selected owner.
As far as displaying anchor is concerned, you can use a check in the anchor tag to see if the selectedOwnerName matches with the owner name in the current for block.
Update
If you want to reset the list on click of anchor then you might want to stop the event propagation so that the event doesn't bubble up to span again.
<td>
<span class="badge badge-pill badge-secondary cursor" (click)="selectedOwnerName = campaign?.CampaignName"> {{ campaign?.CampaignName }} </span>
<a *ngIf="selectedOwnerName == campaign?.CampaignName" (click)="selectedOwnerName=""; $event.stopPropagation()" style="position: relative; left: -16px; top: -1px; color: #fff; font-size: 8px; border: 1px solid #fff; border-radius: 15px; font-weight: bold; cursor: pointer; "><i class="zmdi zmdi-close zmdi-hc-fw"></i> </a>
</td>

Related

how to refresh result count when deleting a row in table using angular

I have one small label where i am showing total result count of one table data.below i am using one table,On that i'm showing list of data.when i'm deleting one row in table,table is refreshing but in that label result count is not refreshing.Here is my data..
import { VsnApplicationsServiceProxy, VsnApplicationDto , CreateOrEditVsnApplicationDto } from '#shared/service-proxies/service-proxies';
#Component({
selector: 'vsn-applicationmappings',
templateUrl: './applicationmappings.component.html',
styleUrls: ['./applicationmappings.component.less'],
encapsulation: ViewEncapsulation.None,
animations: [appModuleAnimation()]
})
export class ApplicationMappingsComponent extends AppComponentBase implements OnInit {
applications: any;
constructor(
injector: Injector,
private _vsnApplicationsServiceProxy: VsnApplicationsServiceProxy,
private _activatedRoute: ActivatedRoute,
) {
super(injector);
}
ngOnInit() {
this._vsnApplicationsServiceProxy.getAll("", "", "", "", "", "", "", 0, 100).subscribe((Applications: any) => {
this.applications = Applications.totalCount;
console.log(' application value', Applications.totalCount);
});
}
getVsnApplications(event?: LazyLoadEvent) {
if (this.primengTableHelper.shouldResetPaging(event)) {
this.paginator.changePage(0);
return;
}
this.primengTableHelper.showLoadingIndicator();
this._vsnApplicationsServiceProxy.getAll(
this.filterText,
this.nameFilter,
this.businessNameFilter,
this.vsnApplicationTypeNameFilter,
this.vsnApplicationCategoryNameFilter,
this.vsnApplicationSubCategoryNameFilter,
this.primengTableHelper.getSorting(this.dataTable),
this.primengTableHelper.getSkipCount(this.paginator, event),
this.primengTableHelper.getMaxResultCount(this.paginator, event)
).subscribe(result => {
this.primengTableHelper.totalRecordsCount = result.totalCount;
this.primengTableHelper.records = result.items;
this.primengTableHelper.hideLoadingIndicator();
});
}
reloadPage(): void {
this.paginator.changePage(this.paginator.getPage());
}
createVsnApplication(): void {
this.createOrEditVsnApplicationModal.show();
}
deleteVsnApplication(vsnApplication: VsnApplicationDto): void {
this.message.confirm(
'',
(isConfirmed) => {
if (isConfirmed) {
this._vsnApplicationsServiceProxy.delete(vsnApplication.id)
.subscribe(() => {
this.reloadPage();
this.notify.success(this.l('SuccessfullyDeleted'));
});
}
}
);
}
<div class="col-sm-2">
<div class="box">
<div><br><br>
<h4>{{applications}}</h4>
</div>
<div> <span>
<h6>Applications</h6>
</span></div>
</div>
</div>
<div class="m-content">
<div class="m-portlet m-portlet--mobile">
<div class="m-portlet__body">
<div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
<p-table #dataTable (onLazyLoad)="getVsnApplications($event)" [value]="primengTableHelper.records"
rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false" [lazy]="true"
[scrollable]="true" ScrollWidth="100%" [responsive]="primengTableHelper.isResponsive"
[resizableColumns]="primengTableHelper.resizableColumns">
<ng-template pTemplate="header">
<tr>
<th style="width: 150px" pSortableColumn="vsnApplicationType.name">
{{l("ApplicationName")}}
<p-sortIcon field="vsnApplication.name"></p-sortIcon>
</th>
<th style="width: 130px"
[hidden]="!isGrantedAny('Pages.Administration.VsnApplicationTypes.Edit', 'Pages.Administration.VsnApplicationTypes.Delete')">
{{l('Actions')}}</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-record="$implicit">
<tr>
<td style="width:150px">
<span class="ui-column-title"> {{l("ApplicationName")}}</span>
{{record.vsnApplication.businessName}}
</td>
<td style="width: 130px"
[hidden]="!isGrantedAny('Pages.Administration.VsnApplications.Edit', 'Pages.Administration.VsnApplications.Delete')">
<div class="btn-group dropdown" dropdown container="body">
<button class="dropdown-toggle btn btn-sm btn-primary" dropdownToggle>
<i class="fa fa-cog"></i><span class="caret"></span> {{l("Actions")}}
</button>
<ul class="dropdown-menu" *dropdownMenu>
<li>
<a href="javascript:;"
(click)="viewVsnApplicationModal.show(record)">{{l('View')}}</a>
</li>
<li>
<a href="javascript:;"
*ngIf="permission.isGranted('Pages.Administration.VsnApplicationTypes.Edit')"
(click)="createOrEditVsnApplicationModal.show(record.vsnApplication.id)">{{l('Edit')}}</a>
</li>
<li>
<a href="javascript:;"
*ngIf="permission.isGranted('Pages.Administration.VsnApplicationTypes.Delete')"
(click)="deleteVsnApplication(record.vsnApplication)">{{l('Delete')}}</a>
</li>
</ul>
</div>
</td>
</tr>
</ng-template>
</p-table>
<div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
{{l('NoData')}}
</div>
<div class="primeng-paging-container">
<p-paginator rows="{{primengTableHelper.defaultRecordsCountPerPage}}" #paginator
(onPageChange)="getVsnApplications($event)"
[totalRecords]="primengTableHelper.totalRecordsCount"
[rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
</p-paginator>
<span class="total-records-count">
{{l('TotalRecordsCount', primengTableHelper.totalRecordsCount)}}
</span>
</div>
</div>
</div>
</div>
<createOrEditVsnApplicationModal #createOrEditVsnApplicationModal (modalSave)="getVsnApplications()">
</createOrEditVsnApplicationModal>
<viewVsnApplicationModal #viewVsnApplicationModal></viewVsnApplicationModal>
</div>
When deleting one row, the table is refreshing and showing updated records.but in that result count lable is not refreshing.I searched in stack overflow,I found that we have to give like splice(id,1)
but it is not working,any suggestions would great help..

Table cells don't match with table headings in Angular 7

I am working on a project which requires me to make table using *ngFor directive of Angular. But after several failed attempts I couldn't get the table layout properly . The table cells don't match up with headings and the width of table rows is also not consistent as you can see in the pic . I'm new to Angular and also don't have much experience in debugging css. I think the problem is due to *ngFor directive. Here is the HTML and CSS code snippet. There is *ngIf condition on each td as the table should show the data in a row only when the user clicks it. I'll be very thankful for any help or guidance given.
* {
color: hsla(210, 100%, 100%, 0.9) !important;
background: hsla(210, 100%, 50%, 0.5) !important;
outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important;
}
.border {
border: 1px solid #cecece;
}
.heading {
width: 100%;
float: left;
}
th {
background-color: #4CAF50;
color: white;
width: 100px;
}
table {
width: 100%;
}
#container {
width: 98.7%;
height: 300px;
overflow-x: scroll;
overflow-y: scroll;
position: fixed;
}
td {
width: 100px;
}
<table class="table table-bordered table-hover">
<thead class="thead-dark">
<tr>
<th class="text-center">registrationNo</th>
<!--adding heading to criterias using *ngFor -->
<div formArrayName="participants" *ngFor="let candidate of myForm.controls.participants['controls'];let i = index;">
<div [formGroupName]="i">
<div formArrayName="criteriaArray" class="d-inline-block" *ngFor="let criteria of candidate.get('criteriaArray').controls;let j = index;">
<div [formGroupName]="j">
<th *ngIf="(i === 0) && (EditRowId2 !== criteria.get('id').value)" class="text-center" style="width: 100%" (click)="Edit2(criteria.get('id').value)">{{criteria.get('criteriaName').value}}</th>
<th *ngIf="(i === 0) && (EditRowId2 === criteria.get('id').value)" class="text-center" style="width: 100%"><input type="text" formControlName="criteriaName"></th>
</div>
</div>
</div>
</div>
</tr>
</thead>
<tbody>
<tr>
<td>Maximum Marks</td>
<!--adding maximum marks row to the table using *ngFor -->
<div (click)="Edit(0)" formArrayName="participants" *ngFor="let candidate of myForm.controls.participants['controls'];let i = index;">
<div [formGroupName]="i">
<div formArrayName="criteriaArray" class="d-inline-block" *ngFor="let criteria of candidate.get('criteriaArray').controls;let j = index;">
<div [formGroupName]="j">
<td *ngIf="(i === 0) && (EditRowId2 !== criteria.get('id').value)" (click)="Edit2(criteria.get('id').value)">{{criteria.get('max_marks').value}}</td>
<td *ngIf="(EditRowId2 === criteria.get('id').value) && (i===0)"> <input type="number" formControlName="max_marks"> </td>
</div>
</div>
</div>
</div>
</tr>
<div formArrayName="participants" *ngFor="let candidate of myForm.controls.participants['controls'];let i = index;" (click)=Edit2(0)>
<div [formGroupName]="i">
<tr>
<td> {{candidate.get('registrationNo').value}} </td>
<div formArrayName="criteriaArray" class="d-inline-block" *ngFor="let criteria of candidate.get('criteriaArray').controls;let j = index;">
<div [formGroupName]="j">
<td *ngIf="EditRowId === candidate.get('id').value"> <input [class.is-invalid]="criteria.errors?.notValid" type="number" formControlName="marks" (click)="changeButtonColor(i)"> </td>
<td [class.is-invalid]="criteria.errors?.notValid" *ngIf="EditRowId !== candidate.get('id').value" (click)="Edit(candidate.get('id').value)">-----</td>
<small *ngIf="criteria.errors?.notValid" class="text-danger">Invalid marks</small>
</div>
</div>
<button *ngIf="candidate.get('dataSaveCheck').value === true" type="button" value="candidate.get('id').value" class="btn btn-primary btn-sm m-2" (click)="saveCandidateForm(candidate , i )" [disabled]='!userForm.form.valid'>save</button>
<button *ngIf="candidate.get('dataSaveCheck').value === false" type="button" value="candidate.get('id').value" class="btn btn-danger btn-sm m-2" (click)="saveCandidateForm(candidate , i )" [disabled]='!userForm.form.valid'>save</button>
</tr>
</div>
</div>
</tbody>
</table>

Cannot reach html templateUrl in Angular 1.6

I'm creating a simple web application in angular 1.6
I create a state for the url "/" but it seems that angular cannot reach the file don´t know why.
Folder structure is this:
So the html load the app like this:
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>paykey</title>
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<!-- -->
<link rel="stylesheet" href="styles/main.css">
</head>
<body ng-app="myApp" >
<script src="node_modules/angular/angular.js"></script>
<script src="node_modules/angular-ui-router/release/angular-ui-router.js"></script>
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.js"></script>
<div ui-view></div>
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/services/codigo.service.js"></script>
</body>
</html>
And the app.js file that has the state is this one:
'use strict';
angular
.module('myApp', [
'ui.router',
'$stateProvider',
'$urlRouterProvider'
])
.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
// .state('home')
.state('main', {
url: '/',
templateUrl: 'views/quote-comps.html',
controller: 'MainT',
controllerAs: 'main'
});
});
So debugging it seems that it passes through stateProvider line but the html does not show up. The only thing I see is the background blonde in css, no errors in console.
The quote-comps.html file is this:
<div ng-controller="MainT" ng-init="init()" style="padding-top: 90px;
padding-left: 20px;">
<div class="bar bar-header disable-user-behavior" >
<div class="header">
<div class="row header-wrapper">
<div class="header-content col text" ng-class="currentPage.title!=undefined ? 'text':''">
<div ng-if="currentPage.title != undefined">
</div>
<img src="images/ICONOS/Logo_banorte_ICO/Logo_Banortexxxhdpi.png" class="bem_image">
<h5 style="text-align: center; color: white; margin-bottom: 0px;margin-top: 0px; font-size: 12px;">Bienvenido</h5>
</div>
</div>
<div class="header-bar" ng-if="currentPage.name.indexOf('login') < 0 && currentPage.name.indexOf('activaToken') < 0 && currentPage.name.indexOf('resynchronize-token') < 0">
<div class="clear"></div>
</div>
</div>
</div>
<div style=" margin-top: 52px;
background-color: #35282B;
height: 450px;
overflow: scroll;">
<h5 style="text-align: center; color: white; font-size: 16px"><!--{{operacion.nombreBeneficario}}-->55 1007 0744</h5>
<h5 style="text-align: center; color: white; ">Has recibido un pago Banorte Móvil por:</h5>
<h3 style="text-align: center; color: white; ">$ {{operacion.importeOperacion}} {{operacion.divisa}}</h3>
<p ng-show="finish" style="text-align: center; font-style: bold; color: white;" ><span>¿Qué deseas hacer?</span></p>
<img ng-show="finish2" class="amount-header ss2" src="../images/ICONOS/Exito_ICO/Exitohdpi.png" >
<p ng-show="finish2" class="amount-header textBox4">¡El deposito fue exitoso!
</p>
<div ng-show="finish" class="comparison-box" ng-class="{'comparison-box-open' : arrowUp}">
<div class="comparison-header-container" ng-click="openMore('first')">
<span> <img style="width: 30px; display:inline;" src="../images/ICONOS/Depositarlo_ICO/Depositarlo.svg"> </img></span>
<span class="comparison-header comboBox">Depositarlo</span>
<img class="arrow" src="images/down_arrow.svg" ng-class="{'rotate180' : arrowUp, 'rotate360' : !arrowUp}">
<!-- <img style="float: right; padding-right: 10px; width: 30px; margin-top: 4px; display: none;" src="images/up_arrow.svg"> -->
</div>
<div class="amounts-container">
<div>
<p style="display: inline;" class="amount-header textBox" ng-class="{'show' : arrowUp && container, 'hide' : !arrowUp}">Ingresa:</p>
<input style="display: inline; text-align: center" class="amount-header inputIngresa" ng-class="{'show' : arrowUp && container, 'hide' : !arrowUp}" placeholder="Cuenta banorte, tarjeta o CLABE">
</div>
<span class="comboBox2"></span>
</div>
<div class="amounts-container">
<div>
<p style="display: inline;" class="amount-header textBox" ng-class="{'show' : arrowUp && container, 'hide' : !arrowUp}">Banco:</p>
<input style="display: inline; text-align: center" class="amount-header inputIngresa" ng-class="{'show' : arrowUp && container, 'hide' : !arrowUp}" placeholder="Cuenta banorte, tarjeta o CLABE">
</div>
<span class="comboBox2"></span>
</div>
<div class="wizard-full">
<!--<button class="btn btn-primary btnSeg seg"> Depositar </button> -->
</div>
<button class="btn cus2" type="submit" ng-click="cancel()">Depositar</button>
</div>
<div ng-show="finish" class="comparison-box seg" ng-class="{'comparison-box-open' : arrowUp2}" style="">
<div class="comparison-header-container" ng-click="openMore('second')">
<span> <img style="width: 30px; display:inline;" src="../images/ICONOS/Depositarlo_ICO/Depositarlo.svg"> </img></span>
<span class="comparison-header comboBox">Cobrarlo en un cajero</span>
<img class="arrow" src="images/down_arrow.svg" ng-class="{'rotate180' : arrowUp2, 'rotate360' : !arrowUp2}" ng-click="restauraE()">
<!-- <img style="float: right; padding-right: 10px; width: 30px; margin-top: 4px; display: none;" src="images/up_arrow.svg"> -->
</div>
<div class="amounts-container">
<div>
<p ng-show="mostrarQuieres" class="amount-header textBox" ng-class="{'show' : arrowUp2 && container, 'hide' : !arrowUp2}">¿Quieres generar tu código de referencia para retirar el efectivo en cajero automático?
</p>
<span>
<img ng-show="mostrarAcude" class="amount-header ss1" src="../images/ICONOS/Exito_ICO/Exitohdpi.png" >
</span>
<div ng-show="mostrarAcude" class="amount-header textbox2" ng-class="{'show' : arrowUp2 && container, 'hide' : !arrowUp2}">Acude a cualquier cajero Banorte, selecciona la opcion retiro de efectivo y captura o escanea este código para retirar tu efectivo
</div>
</div>
</div>
<div class="wizard-full">
<!--<button class="btn btn-primary btnSeg2 seg" ng-click="getCode()"> Generar referencia </button> -->
<button class="btn btn-primary mGenT" type="submit" ng-click="generarTrans()">Generar transferencia</button>
</div>
<div ng-show="mostrar">{{codigoBarras}}
<io-barcode code="123" type="CODE128B"></io-barcode>
</div>
</div>
<div ng-show="mostrar" class="wizard-full">
<button class="btn btn-primary mGenT" type="submit" ng-click="generarTrans()"> d </button>
</div>
</div>
<div class="footer">
"2017 Derechos reservados."</div>
</div>
dependencies:
"dependencies": {
"#uirouter/angularjs": "^1.0.11",
"angular": "^1.6.6",
"bootstrap": "^3.3.7",
"jquery": "^3.2.1"
},
From https://github.com/angular-ui/ui-router/wiki/Multiple-Named-Views
It seems you need to change $state.Provider to something like the following:
$stateProvider
// .state('home')
.state('main', {
url: '/',
views:{
'quoteCompsView':{
templateUrl: 'views/quote-comps.html',
controller: 'MainT',
controllerAs: 'main'
}
}
});
Then in your html add:
<div ui-view="quoteCompsView"></div>
change url:
.state('main', {
url: '/',
views:{
'quoteCompsView':{
templateUrl: '../views/quote-comps.html',// -------- Here
controller: 'MainT',
controllerAs: 'main'
}
}
You are not adding reference in your main index html file .
I dont see any controller reference on html page
I edited the controller...
angular.module('myApp',[])
.controller('MainT', MainT);
to
angular.module('myApp')
.controller('MainT', MainT);
and works... I really don't know why

CSS position fixed moved childrens

I'm trying to create chat just like facebook or google. I have created chat-container class which holds users list and chat boxes.
chat-container is fixed with bottom:0 and right: 0, so its position is perfect.
.chat-container {
position: fixed;
bottom: 0;
right: 0;
padding: 5px;
}
The problem is that I am getting a lot of users from server. So, I would like to add max-height: value. When I add this property then all my chat-boxes include userslist is being misaligned.
Each chat box has class chat-box and and inside chat-body..chat-box
.chat-box {
display: inline-block;
max-width: 300px;
min-width: 100px;
}
.chat-body {
max-width: 500px;
min-width: 100px;
overflow-y: scroll;
max-height: 200px;
}
How can I solve that?
EDIT - HTML:
<div class="chat-container">
<div class="chat-box" *ngFor="let chat of openedChats; let first = first;">
<p-panel [toggleable]="true">
<p-header>
<a class="ui-panel-titlebar-icon ui-panel-titlebar-toggler ui-corner-all ui-state-default" (click)="onCloseChat(chat)">
<span class="fa fa-fw fa-close"></span>
</a>
<b>{{chat.recipient.name}}</b>
</p-header>
<div class="chat-body" #chatbody>
<div *ngFor="let message of chat.messages">
<!--TODO: Get current user id | change to ngClass-->
<div *ngIf="message.sender.id != loggedUserId" class="chat-inner-message">
{{message.message}}
</div>
<div *ngIf="message.sender.id == loggedUserId" class="chat-my-message">
{{message.message}}
</div>
</div>
</div>
<hr>
<input type="text" class="chat-input" (keyup.enter)="onSendMessage(messageInput, chat.recipient.id)" #messageInput>
<button pButton type="button" label="Send" (click)="onSendMessage(messageInput, chat.recipient.id)" style="width:100%"></button>
<!--<span *ngIf='first'>{{setChatInputFocus()}}</span>-->
</p-panel>
</div>
<div class="chat-box">
<p-panel [toggleable]="true" [collapsed]="true">
<p-header>
Chat
</p-header>
<ul class="ultima-menu">
<li *ngFor="let user of visibleUsers" (click)="onUserSelected($event, user.id)" style="padding: 3%">
<div style="display: inline; cursor: pointer;">
<div>
<img style="vertical-align:middle" src="{{user?.settings?.photoSrc}}" class="circular-portrait" width="30px" height="30px"
alt="{{user.name}}">
<span>
{{user.name}} {{user.surname}}
</span>
</div>
</div>
</li>
</ul>
<hr>
<input pInputText placeholder="Search" [ngModel]="userTypeaheadText" (ngModelChange)="userTypeahedChanged($event)">
</p-panel>
</div>
</div>

How can I add and synchronize a scrollbar at the top and bottom of a div?

I'm trying to create top and bottom scrollbars on a table in angular1 using a directive. Although it creates the scroll bars the top scrollbar thumb doesn't appear even if there is an overflow in the table. Below is the code. Where exactly am I going wrong here?
angular.module('app.doubleHorizontalScrollDirective', []).directive('doubleHorizontalScroll', [
'$interval',
function($interval){
return {
restrict: 'A',
link: function(scope, element, attr) {
// ng-repeat delays the actual width of the element.
// this listens for the change and updates the scroll bar
function widthListener() {
if (anchor.width() !== lastWidth)
updateScroll();
}
function updateScroll() {
// for whatever reason this gradually takes away 1 pixel when it sets the width.
$div2.width(anchor.width());
// make the scroll bars the same width
$div1.width($div2.width());
// sync the real scrollbar with the virtual one.
$wrapper1.scroll(function(){
$wrapper2.scrollLeft($wrapper1.scrollLeft());
});
// sync the virtual scrollbar with the real one.
$wrapper2.scroll(function(){
$wrapper1.scrollLeft($wrapper2.scrollLeft());
});
}
let anchor = element.find('[data-anchor]'),
lastWidth = anchor.width(),
listener;
// so that when you go to a new link it stops listening
element.on('remove', function() {
listener.cancel();
});
// creates the top virtual scrollbar
element.wrapInner("<div class='div2' />");
element.wrapInner("<div class='wrapper2' />");
// contains the element with a real scrollbar
element.prepend("<div class='wrapper1'><div class='div1'></div></div>");
let $wrapper1 = element.find('.wrapper1'),
$div1 = element.find('.div1'),
$wrapper2 = element.find('.wrapper2'),
$div2 = element.find('.div2');
// force our virtual scrollbar to work the way we want.
$wrapper1.css({
width: "100%",
border: "none 0px rgba(0, 0, 0, 0)",
overflowX: "scroll",
overflowY: "hidden",
height: "20px",
});
$div1.css({
height: "20px",
});
$wrapper2.css({
width: "100%",
overflowX: "scroll",
});
listener = $interval(function() {
widthListener();
}, 1000);
updateScroll();
}
};
}]);
HTML:
<div id="scroll-container"
double-horizontal-scroll>
<div data-anchor>
<div class="video-analysis__default_table__header">
<table>
<tr>
<th class="video-analysis__default_table__header--index fixed-left-index "><!--<i class="fa fa-caret-up"></i>--></th>
<th class="video-analysis__default_table__header--checkbox fixed-left-checkbox"><div class="relative"></div></th>
<th class="video-analysis__default_table__header--star fixed-left-star" ng-click="sortClips('starred')">
<div class="relative">
<i ng-show="isSortType('starred') && sortDirection == 1" class="fa fa-caret-up"></i>
<i ng-show="isSortType('starred') && sortDirection == -1" class="fa fa-caret-down"></i>
</div>
</th>
<th ng-repeat="header in currentHeaders"
ng-class="'video-analysis__default_table__header--' + header.class"
ng-click="sortClips(header.sorting_column)"
>
<span ng-bind="header.header_title"></span>
<i ng-show="isSortType(header.sorting_column) && sortDirection == 1" class="fa fa-caret-up"></i>
<i ng-show="isSortType(header.sorting_column) && sortDirection == -1" class="fa fa-caret-down"></i>
</th>
<th ng-show="emptySpaceExists()"
ng-style="{'width' : remainingWidth + 'px'}">
</th>
<th class="video-analysis__default_table__header--plus fixed-right"
ng-click="show_table_data = !show_table_data; $event.stopPropagation();">
<span class="fa fa-cog fa-2x" ng-show="show_table_data"></span>
<span class="fa fa-minus-square-o fa-2x" ng-hide="show_table_data"></span>
</th>
</tr>
</table>
</div>
<div class="video-analysis__default_table__item" ng-hide="!show_table_data">
<div class="panel video-analysis__default_table__item__panel"
ng-repeat="item in clips track by $index"
ng-init="is_collapsed = true;"
ng-style="{'margin-bottom' : !is_collapsed ? '150px' : '0px'}"
>
<div class="panel-body video-analysis__default_table__item__panel__body">
<table>
<tbody id="clip_data_table">
<tr class="clickable" ng-click="playClip(item)" ng-mouseenter="color = 'clip-hover'" ng-mouseleave="color = ''">
<td class="video-analysis__default_table__item__panel__body--index fixed-left-index"
>
<div class="relative" ng-bind="$index + 1" ng-class="color"></div>
</td>
<td class="video-analysis__default_table__item__panel__body--checkbox fixed-left-checkbox">
<div class="relative" ng-class="color">
<input type="checkbox" ng-click="toggleClipCollection(item); $event.stopPropagation();" ng-checked="is_InClipCollection(item)">
</div>
</td>
<td class="video-analysis__default_table__item__panel__body--star fixed-left-star">
<div class="relative" ng-class="color">
<i class="fa fa-favorite"
ng-click="toggleStarredClip(item); $event.stopPropagation();"
ng-class="{active: isStarredClip(item)}"
>
</i>
</div>
</td>
<td ng-repeat="column in currentHeaders"
ng-class="'video-analysis__default_table__item__panel__body--' + column.class +' '+color"
>
<span ng-bind="getClipDatum(column.sorting_column, item)"></span>
</td>
<td ng-show="emptySpaceExists()"
ng-style="{'width' : remainingWidth + 'px'}">
</td>
<td class="video-analysis__default_table__item__panel__body--plus fixed-right"
ng-click="is_collapsed = !is_collapsed; $event.stopPropagation();">
<div class="relative" ng-class="color">
<span class="fa fa-plus-square fa-2x" ng-show="is_collapsed"></span>
<span class="fa fa-minus-square-o fa-2x" ng-hide="is_collapsed"></span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="panel-footer video-analysis__default_table__item__panel__footer"
ng-hide="is_collapsed">
<div class="col-md-5 padding-0">
<table>
<tr class="teams-row">
<th class="team-name-column" ng-bind="item.game.awayteam.abbrev"></th>
<th class="positions-column"></th>
<th class="team-name-column" ng-bind="item.game.hometeam.abbrev"></th>
</tr>
<tr ng-show="item.lineup.length === 0"
ng-repeat="position in positions"
>
<td class="player-name-column text-center"><span ng-if="$index == 3">Data Not Available</span></td>
<td class="positions-column border-left-right"><span ng-bind="position"></span></td>
<td class="player-name-column text-center"><span ng-if="$index == 3">Data Not Available</span></td>
</tr>
<tr ng-show="item.lineup.length !== 0"
ng-repeat="(position_key, position) in item.lineup"
>
<td class="player-name-column text-left">
<span class="player-name"
ng-bind="'#'+position.away.iplayerjerseynumber+' '
+position.away.abbrev_name">
</span>
</td>
<td class="positions-column border-left-right">
<span ng-bind="position_key"></span>
</td>
<td class="player-name-column text-left">
<span class="player-name"
ng-bind="'#'+position.home.iplayerjerseynumber+' '
+position.home.abbrev_name">
</span>
</td>
</tr>
</table>
</div>
<div class="col-md-5 padding-0">
<div class="video-analysis-col-notes">
<div class="notes-title">
<span>notes: </span>
<button class="edit-button"
ng-click="toggleForm(notesEform)">
<span ng-show="notesEform.$visible">
<i class="fa fa-check"></i>save
</span>
<span ng-show="!notesEform.$visible">
<i class="fa fa-pencil"></i>edit
</span>
</button>
</div>
<div class="notes-content"
editable-textarea="item.detailed_notes"
buttons="no"
blur="submit"
onaftersave="saveXeditable(item.iclipid, item);"
e-form="notesEform"
ng-bind="item.detailed_notes"
>
</div>
</div>
</div>
<div class="col-md-2 padding-0">
<div class="dropdown-actions">
<div class="padding-2px">
<button class="action-button" ng-click="playClip(item)">play</button>
<button class="action-button" ng-click="editClip(item)">edit clip</button>
<!--<button class="action-button">add to playlist</button>-->
<!--<button class="action-button">share</button>-->
<button class="action-button" ng-click="syndicateClip(item)">syndicate</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
#scroll-container {
margin-left: 106px;
margin-right: 40px;
}