我现在对angular 7刚开始使用angular。任何帮助都会有所帮助。
单击按钮时,我无法创建 Chrome 警报对话框。
<button mat-raised-button matStepperNext color="primary" [disabled]="formGroup.invalid" (click)="window.alert('Thanks for your submission!')>Submit</button>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
Angular 7 - primeng - 确认对话框不起作用
HTML
<p>confirm-dialog</p>
<button type="button" (click)="confirm()" pButton icon="pi pi-check" label="Confirm"></button>
Run Code Online (Sandbox Code Playgroud)
打字稿
confirm() {
console.log('confirm called...')
this.confirmationService.confirm({
message: 'Are you sure that you want to proceed?',
header: 'Confirmation',
icon: 'pi pi-exclamation-triangle',
accept: () => {
this.msgs = [{ severity: 'info', summary: 'Confirmed', detail: 'You have accepted' }];
console.log('accept...')
},
reject: () => {
this.msgs = [{ severity: 'info', summary: 'Rejected', detail: 'You have rejected' }];
}
});
Run Code Online (Sandbox Code Playgroud)
Stackblitz 上的完整代码
https://stackblitz.com/edit/jjay-angular-primeng-gaiizg?file=src%2Fapp%2Fapp.module.ts
我的组件代码 -
import { Component, EventEmitter, Input, OnInit, OnChanges, SimpleChanges, Output } from '@angular/core';
import { CI, CiWithStatus } from '../ci-list.service';
import { ContextPanelApi } from '../../../../../../../../shared/shared-html/js/directives/oprContextPanel/oprContextPanel/oprContextPanelApi.service';
@Component({
selector: 'opr-watchlist-cards',
templateUrl: './watchlist-cards.component.html',
styleUrls: ['./watchlist-cards.component.scss']
})
export class WatchlistCardsComponent implements OnInit, OnChanges {
@Input() ciList: CiWithStatus[];
@Input() itemWidth: number;
@Input() itemHeight: number;
@Input() zoomLevel: number;
@Output() onSelectedCisChanged: EventEmitter<CI[]> = new EventEmitter<CI[]>();
private _selectedItems: CI[] = [];
constructor(private _oprContextPanelApiService: ContextPanelApi) {
}
ngOnInit() {
console.debug('ciList', this.ciList);
}
ngOnChanges(changes: SimpleChanges): void {
if(changes.zoomLevel) …Run Code Online (Sandbox Code Playgroud) 我的 index.html 中有以下内容
<!doctype html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8">
<title>Halls Gate</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="assets/img/favicon.png">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Istok+Web" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我想<html dir="ltr" lang="en">根据所选语言从组件更新 html 元素中的 dir 和 lang 属性。
有没有办法在 Angular 中解决这个问题?
谢谢你。
我想使用此代码在 Firestore 中按“员工”文档的“全名”排序。
在 service.ts
getEmployees() {
return this.firestore.collection('employee').snapshotChanges();
}
Run Code Online (Sandbox Code Playgroud)
在 Component.ts 中
ngOnInit() {
this.service.getEmployees().subscribe(actionArray => {
let array = actionArray.map(item => {
return {
id: item.payload.doc.id,
...item.payload.doc.data()
};
});
....
}
Run Code Online (Sandbox Code Playgroud)
我是初学者。我需要对此代码进行哪些更改才能获得所需的输出。谢谢
我正在使用 Angular 7 和 Angular Material 从 api 获取用户名。为此,我使用了角材料芯片。这是链接,我正在关注:
https://stackblitz.com/angular/jemmxnqdyro?file=app%2Fchips-autocomplete-example.ts
但问题是目前我正在从数组中获取数据。我真正需要的是从这个 api 中获取用户名:https : //jsonplaceholder.typicode.com/users。我感到困惑的是如何使用角材料芯片以及如何获取数据。
你能帮我实现同样的功能吗,因为我是 angular 的新手。
如果有人可以在这方面展示演示,那将非常有帮助。
提前致谢。
我在Angular 7应用中遇到以下错误:
Property 'post' does not exist on type 'HttpClient'
Run Code Online (Sandbox Code Playgroud)
我正在使用的代码如下:
import { Injectable } from '@angular/core';
import { Car } from '../models/car';
import cars from '../cars/car-list';
import { HttpClient } from 'selenium-webdriver/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class CarService {
private cars: Car[];
constructor(private http:HttpClient) {
this.cars = cars;
}
addCar(car: Car): Observable<any> {
this.cars.push(car);
return this.http.post('http://localhost:3000/cars', car);
}
Run Code Online (Sandbox Code Playgroud)
您能帮我解决这个错误吗?
在此先感谢您的帮助。
ag-grid 社区 v20,Angular 7。
我ag-grid在我的Angular 7应用程序中有一个工作。我想在一列中显示图像。该https地址包含在列field。我搜索了 ag-grid 的文档和网络,但没有找到这个基本场景的例子。有人可以为columnDef. 是cellRenderer这样做的方法吗?
{ headerName: 'Select', field: 'Image', width: 75, sortable: false,
cellRenderer: '<span><img border="0" width = "15" height="10" src=xxxx ></span>' },
Run Code Online (Sandbox Code Playgroud) 我想在我的 labelbind 中创建一个带有 2 个值的 ng-select 目前我的 ng-select 如下
<ng-select [items]="mentorSessions"
[multiple]="false"
[closeOnSelect]="true"
[searchable]="true"
bindLabel="name"
[ngModelOptions]="{standalone: true}"
[(ngModel)]="mentorToShareTo">
</ng-select>
Run Code Online (Sandbox Code Playgroud)
我希望 bindLabel 是这样的
bindLabel="name" + ":" +"profession"
Run Code Online (Sandbox Code Playgroud)