मैं कोणीय 4 के लिए काफी नया हूं और मैं अपने चर के मान को "घंटों" से "दिनों" में बदलना चाहता हूं और मेरे द्वारा ngModel द्वारा दिए गए मान को भी विभाजित करना चाहता हूं 8. मैं इसे करने के लिए वास्तव में कैसे जाऊं?कोणीय 4 - एक चर के मूल्य को बदलने के लिए मैं अपना चेकबॉक्स कैसे प्राप्त कर सकता हूं?
यहाँ मेरी summary.component.html से एक अंश है:
import { Component, OnInit } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { EmpInfoService } from './emp-info.service';
import { EmpInfo } from './emp-info';
@Component({
selector: 'pto-summary',
templateUrl: `./summary.component.html`,
styleUrls: ['./summary.component.css']
})
export class SummaryComponent implements OnInit{
empInfo: EmpInfo[];
selectedIndex = 4;
timeVar = " hours";
constructor(private empInfoService: EmpInfoService) { }
getEmpInfo(): void {
this.empInfoService.getEmpInfos().then(
empInfo => this.empInfo = empInfo
);
}
ngOnInit(): void {
this.getEmpInfo();
}
}
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
<div class="panel-body">
<form class="form-horizontal" role="form" style="overflow-x:auto;">
<fieldset>
<div class="col-xs-6">
<div class="form-group" *ngIf="empInfo && empInfo.length > selectedIndex">
<label class="col-xs-2" style="font-weight: bold;"> + </label>
<label class="col-xs-4"> Carryover </label>
<div class="col-xs-6">
<input class='form-control' type="text" id="ptoCarry" [(ngModel)]="empInfo[selectedIndex].PTOCarry + timeVar" name="ptoCarry"/>
</div>
</div>
</div>
</fieldset>
</form>
</div>
और फिर मेरी summary.component.ts है
export class EmpInfo {
EmpKey: number;
EmpID: string;
Firstname: string;
LastName: string;
EmpStat: string;
StartDate: Date;
AdjustedStart: Date;
Anniversary: number;
PTOYear: number;
STDLTD: number;
Uncharged: number;
ETOEarned: number;
ETORequests: number;
ETORemaining: number;
PTOBase: number;
PTOCarry: number;
PTOBorrowed: number;
PTOBalance: number;
PTORequests: number;
PTORemaining: number;
}
किसी भी मदद की बहुत सराहना और स्वागत किया जाता है:यहाँ मेरी empInfo वस्तु है! अग्रिम में धन्यवाद!
ngModel में 'empInfo [selectIndex] [PTOCarry + timeVar] होना चाहिए, क्या आप' empInfo' ऑब्जेक्ट को साझा कर सकते हैं? –
मैं इसे 2 डी सरणी के रूप में कैसे लिखूं? और मूल पोस्ट को अद्यतन करना। – asdf