- Я ХОЧУ ДОСТУПАТЬ к значению = имя_ решения: "В ОЖИДАНИИ" из вложенного json объекта массива в angular ИМЯ РЕШЕНИЯ: "В ОЖИДАНИИ" :: ДАН В ИЗОБРАЖЕНИИ
- также я хочу получить значение solutionName: "PENDING" из вложенного json объекта массива и хотите показать тот объект в таблице, который присутствует в файле AccountypeChecker.ts
master.ts file
import { Component, OnInit } from '@angular/core';
import { master } from '../master';
import { MasterService } from './master.service';
import { accounttype } from '../account-type';
import { AccountTypeCheckerService } from '../account-type-checker/account-type-checker.service';
import {vip} from '../vip'
import { variable } from '@angular/compiler/src/output/output_ast';
import { Variable } from '@angular/compiler/src/render3/r3_ast';
@Component({
selector: 'app-master',
templateUrl: './master.component.html',
styleUrls: ['./master.component.css'],
template: `<div class="container d-flex justify-content-center">
<div [hidden]="isShow" class="panel panel-primary col-md-8">
<div class="panel-header">
Checker
</div>
<div class="panel-body">
<form class="col-md-8 pt-4 pb-4 justify-content-center form-inline">
<label>Master Name:</label>
<select class="form-control" [(ngModel)]="maste" id="maste" name="maste">
<option *ngFor="let maste of masters" [ngValue]="maste">{{maste}}</option>
</select>
<br />
<br/>
<br/>
<br/>
<br/>
<button type="submit" class="btn btn-primary btn-lg" (click)="onSubmit(maste)">Submit</button>
<button type="reset" class="btn btn-primary btn-lg">Reset</button>
</form>
</div>
</div>
<div>
<app-account-type-checker [showmeData]="variable" [showMePartially]="showVar"></app-account-type-checker>
</div>
</div>`
})
класс экспорта MasterComponent реализует OnInit {
BASEURI = 'http://localhost:8080/certification/certify/';
BASEURI2 = 'http://localhost:8080/certification/getList/';
BASEURI3 = 'http://localhost:8080/acctype/getAll';
masters: Array<master>[];
masterData: any
ref: string;
showVar: boolean = false;
accountType: Array<accounttype>[];
variable: Array<any> = [];
variablep: string = "DATA";
constructor(
private accountTypeCheckerService: AccountTypeCheckerService,
private masterservice: MasterService,
) { }
ngOnInit() {
this.getMaster();
}
getMaster() {
this.masterservice.fetchAllPendingMasters().subscribe(
data => {
this.masters = data['data']['Populate Masters'];
console.log(this.masters)
}, err => {
console.log("err", err);
}
)
}
onSubmit (_ref): void {this.showVar = true; console.log (_ref) this.variable.pu sh (this.accountTypeCheckerService.getAllAccDetails (_ref) .subscribe (_data => {this.variable = _data ['data'] console.log (this.variable, "master) data ") console.log (this.variable +" VARIABLEEEEEEEEEE "); this.variable}
hhh() {
console.log(this.variable)
}
}
AccountypeChecker.ts file
import { Component, OnInit, Input } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { master } from '../master';
import { AccountTypeCheckerService } from './account-type-checker.service';
import { MasterComponent } from '../master/master.component';
@Component({
selector: 'app-account-type-checker',
templateUrl: './account-type-checker.component.html',
styleUrls: ['./account-type-checker.component.css'],
template:`<div *ngIf="showMePartially" class="container">
<body>
<div style="overflow-x:auto;">
<table class="table1 table-striped table-grid table-responsive-md table-bordered">
<thead>
<tr >
<th>Master Name</th>
<th>Action</th>
<th>Accept</th>
<th>Reject</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let acc of showmeData | keyvalue">
<td>{{acc}}</td>
<td>Action</td>
<td class="demo-checkbox label"><input type="checkbox" name="chk1"/></td>
<td><input type="checkbox" name="chk2"/></td>
<td><input type="text" name="txt"></td>
</tr>
</tbody>
</table>
<br/>
<div><button style="margin-left: 5cm;" type="submit" class="btn btn-primary btn-lg">Certify</button></div>
</div>`
})
export class AccountTypeCheckerComponent implements OnInit {
@Input() showmeData: Array<any> = [];
BASEURI2 = 'http://localhost:8080/certification/getList/';
@Input() showMePartially: boolean;
masters:Array<master>[];
masterData:any
ref:string;
AllData: any;
constructor(private router:Router, private http:HttpClient,
private activatedRoute:ActivatedRoute,
private accountTypeCheckerService:AccountTypeCheckerService,
//private MasterService : MasterService,
private MasterComponent : MasterComponent
) {
console.log(this.showmeData + "@@@@@@@@@@@@@@@@@@@@@@@@");
}
ngOnInit() {
}
CONSOLE ::::::::::::::::::::::::::
DECISION CERTIFICATION: Array(4)
0:
key:
decisionId: 4
decisionName: "PENDING"
decisionCreatedDate: "2020-02-13T10:03:33.535+0000"
decisionCreatedBy: "adi"
decisionModifiedDate: null
decisionModifiedBy: null
decisionCertified: 1
__proto__: Object
value:
decisionTrailId: 5
decision: {decisionId: 4, decisionName: "PENDING", decisionCreatedDate: "2020-02-13T10:03:33.535+0000", decisionCreatedBy: "adi", decisionModifiedDate: null, …}
decisionName: "PENDING" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<I WANT THIS TO SHOW IN A TABLE
decisionCreatedDate: "2020-02-13T10:03:33.535+0000"
decisionCreatedBy: "adi"
decisionModifiedDate: null
decisionModifiedBy: null
decisionCertifed: 1
decisionCertMode: null
decisionAction: "NEW"
decisionRemark: "VALUE CREATED"
__proto__: Object
__proto__: Object
1: {key: {…}, value: {…}}
2: {key: {…}, value: {…}}
3: {key: {…}, value: {…}}
length: 4
}