我的 Angular 组件中有返回数据的方法
这是这个方法
getRecognitionById() {
this.loaderService.show(null, true);
forkJoin(
this.vendorWebApiService.getRecognitionById(this.executiveChangeId),
this.vendorWebApiService.getLatestFeedback(this.executiveChangeId)).pipe(take(1))
.subscribe(res => {
this.recognitionData = res[0];
this.latestFeedback = res[1];
this.generateResponseFeedbackGroup();
this.loaderService.hide(true);
});
}
Run Code Online (Sandbox Code Playgroud)
我需要检查 8 秒内是否没有响应,提醒用户alert(response.exceptionMessage);
我怎样才能做到这一点?
我有Angular组件
这是代码
@Component({
selector: 'app-testcomponent',
templateUrl: './testcomponent.component.html',
styleUrls: ['./testcomponent.component.scss']
})
export class TestcomponentComponent implements OnInit {
version: string = environment.version;
error: string;
searchForm: FormGroup;
constructor(
private formBuilder: FormBuilder,
private http: HttpClient
) {
this.createForm();
}
ngOnInit() {}
search() {
this.http.get('https://api.chucknorris.io/jokes/search?query='+this.searchForm.value.jokevalue ).subscribe(
data => [
console.log(data)
])
}
private createForm() {
this.searchForm = this.formBuilder.group({
jokevalue: ['', Validators.required],
});
}
}
Run Code Online (Sandbox Code Playgroud)
函数search()与从API获取值并为提交按钮上的数组中的每个元素制作html标记相关.这是模板html
<div class="container-fluid">
<form class="form-inline" (ngSubmit)="search()" [formGroup]="searchForm" novalidate>
<label for="text">Enter value:</label>
<input formControlName="jokevalue" style="margin-left:20px;" type="text" class="form-control" id="email">
<button style="margin-left:20px;" …Run Code Online (Sandbox Code Playgroud) 我需要通过提交按钮从API获取数据
这是网址-https : //api.chucknorris.io/jokes/search ? query = ******
*****是来自输入的值
这是API的回应
{
"total": 1,
"result": [
{
"category": null,
"icon_url": "https://assets.chucknorris.host/img/avatar/chuck-norris.png",
"id": "cq6hLP0ETeW4VSrm7SYg5A",
"url": "https://api.chucknorris.io/jokes/cq6hLP0ETeW4VSrm7SYg5A",
"value": "Chuck Norris knows WAZZZUP!"
}
]
Run Code Online (Sandbox Code Playgroud)
}
我需要从结果中获取价值并将其显示在View中
如您所见,它是一个对象,而不是array。
我试图这样
模板代码
<div class="container-fluid">
<form class="form-inline" (ngSubmit)="search()" [formGroup]="searchForm" novalidate>
<label for="text">Enter value:</label>
<input formControlName="jokevalue" style="margin-left:20px;" type="text" class="form-control" id="email">
<button style="margin-left:20px;" type="submit" class="btn btn-primary">Submit</button>
</form>
<div style="background: black; height: 60px;" *ngFor="let joke of jokes;index as i">
<p style="color: white">{{i}}</p>
<p style="color: white">{{joke.result[i].value}}</p>
</div>
Run Code Online (Sandbox Code Playgroud)
组件代码
import …Run Code Online (Sandbox Code Playgroud) 我使用了 Angular 的材质对话框,我需要在其中输入标题并选择批准或拒绝变体。
这里的组件代码
import {Component, Inject, OnInit} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material";
import {FormBuilder, Validators, FormGroup} from "@angular/forms";
import { Payment } from '../payments/payment';
@Component({
selector: 'editing-dialog',
templateUrl: './editing-dialog.component.html',
styleUrls: ['./editing-dialog.component.scss']
})
export class EditingDialogComponent implements OnInit {
form: FormGroup;
reason:String;
id: Number;
statusdescription: String;
constructor(
fb: FormBuilder,
private dialogRef: MatDialogRef<EditingDialogComponent>,
@Inject(MAT_DIALOG_DATA) data:Payment) {
this.reason = data.Reason;
this.id = data.Id;
this.statusdescription = data.StatusDescription;
this.form = fb.group({
reason: [this.reason, Validators.maxLength(5)],
id: this.id,
status: status
});
}
ngOnInit() { …Run Code Online (Sandbox Code Playgroud) 我有sql server脚本,我需要转换为Redshift
这是我遇到问题的代码的一部分
IIF(smf.channelid IS NULL, 0, 1) AS IsFeatureKey,
IIF(codeLabel.CslId > 0, 1, 0) AS IsCslCode,
IIF(codeLabel.LearnId > 0, 1, 0) AS IsLearnCode,
IIF(codeLabel.PMId > 0, 1, 0) AS IsPMCode,
IIF(codeLabel.UpSell > 0, 1, 0) AS IsUpSell
Run Code Online (Sandbox Code Playgroud)
我怎样才能正确地将它转换为Redshift?
我有需要下载文件并转换为 Base64 字符串的 url
我写了这段代码来做到这一点
private string GetImageAsBase64(string url)
{
using (var client = new WebClient())
{
var bytes = client.DownloadData(url);
var base64String = Convert.ToBase64String(bytes);
return base64String;
}
}
Run Code Online (Sandbox Code Playgroud)
如何使其异步使用返回类型Task<string>?
我有方法,要检查房东的数目?房东类型
我有这段代码来检查它
var type = _landlordTypeRepository.GetAll()
.Include(x => x.Landlords)
.FirstOrDefault(x => x.Id == input.Id);
if (type.Landlords.Count > 0)
{
throw new UserFriendlyException(L("ThisTypeIsInUse"));
}
Run Code Online (Sandbox Code Playgroud)
但是我这样改写了
var type = _landlordTypeRepository
.GetAll()
.AnyAsync(x=> x.Id == input.Id && x.Landlords.Any());
Run Code Online (Sandbox Code Playgroud)
但是现在返回类型ID Task<bool>
如果我该如何使用呢?
我有一个从后端获取数据的 Angular 组件。
这是组件的代码
export class MessagesComponent implements OnInit {
constructor(private _router: Router, private http: HttpClient) {
}
timer: any;
chats: any;
autoresize: boolean = false;
chatId: number;
moment: any = moment;
chatMessages: any;
messageToSend: string;
messageObject: CreateMessageDto = new CreateMessageDto();
ngOnInit(): void {
this.getChatsList();
}
getChatsList(): any {
var reqHeader = new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + localStorage.getItem('jwt'),
});
return this.http
.get(environment.baseUrl + '/Chat/GetUserChats', {
headers: reqHeader,
})
.subscribe((data: any) => {
this.chats = data.reverse();
this.getChatId(data[0].id);
}); …Run Code Online (Sandbox Code Playgroud) angular ×5
javascript ×5
typescript ×5
c# ×2
css ×2
html ×2
asp.net ×1
asp.net-core ×1
rxjs ×1
sql ×1
sql-server ×1