如何以角度模板驱动形式使用垫自动选择来设置过滤器。
<mat-form-field class="pl">
<input matInput name="item_id"
[(ngModel)]="stock.item_id"
#item_id="ngModel"
placeholder="Item"
[matAutocomplete]="auto" required>
<mat-autocomplete #auto="matAutocomplete" [displayWith]="valueMapper">
<mat-option *ngFor="let item of itemsData" [value]="item.id">
{{item.text}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
请参阅 stackblitz 示例:单击此处
我尝试在单行中使用 CDK 拖放,它工作得很好,同样,它对于单列也工作得很好,但当我使用flex-wrap: wrap在行和列中显示图块时,它无法正常工作。
我在 Angular 中有一个 Moment 类型的数据类型,每次它在 Angular 中显示时,它都会显示为
<div>{{dateStart}}</div>
Fri Mar 08 2019 20:24:35 GMT-0800
Run Code Online (Sandbox Code Playgroud)
如何显示“3/8/2019”?
如果在 Typescript 中进行转换,我们必须采用现有的类,并使用最后两种数据类型作为日期重新创建新类。只是好奇 HTML 或 Pipe 函数中是否有 Displayformat Angular?在哪里转换成HTML?
export class Address {
fullName: string;
mailingAddress: string;
phoneNumber: string;
emailAddress: string;
dateStart?: moment.Moment;
dateEnd?: moment.Moment;
Run Code Online (Sandbox Code Playgroud)
资源问题:
我正在创建一个部署在 firebase 上的 Angular8 通用应用程序。引用了这个网站Angular universal with firebase
当我在本地使用 Express 服务器运行并提供应用程序时,所有路由都将加载更新的元标记。当我在 firebase 上部署应用程序时,一切正常,但根路径上的元标记没有更新。它们对于所有其他路线都工作得非常好。当我打开检查元素时,元标记也会更新。我添加了一些配置,以便不在 firebase.json How to Prevent caching for the index.html of an SPA上缓存 html 文件,并将 server.ts 文件中的“cache”值设置为“No-cache”,如下所示
app.get('*', (req, res) => {
res.set('Cache-Control', 'public, max-age=0, s-maxage=0, no-cache');
res.render('index', { req });
});
Run Code Online (Sandbox Code Playgroud)
但对我来说没有任何作用。请帮忙。
firebase-hosting google-cloud-functions angular-universal angular angular8
差异加载是一种策略,其中 CLI 构建两个单独的包作为已部署应用程序的一部分。
Angular CLI 版本 8 及更高版本默认支持差异加载。对于工作区中的每个应用程序项目,您可以根据应用程序项目中的 browserslist 和 tsconfig.json 文件配置如何生成构建。
如果我们有两个具有差异加载功能的独立捆绑包,是否会导致构建大小问题和应用程序性能?
请分享您的建议,以便我可以在我当前的项目中选择此功能。
我有路径让路径="/";
当它调用这个路径时,Angular 会生成这样的路径:
http://localhost:4200/backend/api
Run Code Online (Sandbox Code Playgroud)
但是我需要
http://localhost/backend/api
Run Code Online (Sandbox Code Playgroud)
没有端口,如何在 Angular 中设置此选项?
我想将登录用户数据存储在角度8的本地存储中,并获取该用户的数据。在此,我没有使用 Firebase 身份验证服务。
这是我的登录代码
login(empId: string, password: string){
return this.af.database.ref('Users/' +empId).once('value').then(
snap =>{
var userPassword = (snap.val() && snap.val().password)
if(password == userPassword){
// this.router.navigate(['dashboard']);
}
else{
console.log("Incorrect Password")
}
}
)
}
Run Code Online (Sandbox Code Playgroud) 当我们在服务中使用ngOnInit时?
例如,我需要监听服务内的观察者:
this.eventService.subscribe((data) => {
});
Run Code Online (Sandbox Code Playgroud)
将此代码放在构造函数或 ngOnInit 中哪里更好?
我正在尝试使用 Angulars ControlValueAccessor 创建自定义元素。目标是具有三种状态的开关:真、假和空。默认情况下应选择 Null,我尝试了其他帖子中的一些解决方案,但它们不起作用。
我尝试在 mat-button-toggle-group 中添加“value=null”,并在 null mat-button-toggle 本身中添加“checked”属性。
HTML:
<div class="nullableBoolWrapper" fxLayout="row">
<mat-label class="centred-vertically">{{ label }}</mat-label>
<mat-button-toggle-group class="selection-button"
[disabled]="isDisabled"
[(ngModel)]="selectedValue"
(change)="changed($event)">
<mat-button-toggle ngDefaultControl value=true>{{ descriptionList[0].description }}</mat-button-toggle>
<mat-button-toggle ngDefaultControl value=false>{{ descriptionList[1].description }}</mat-button-toggle>
<mat-button-toggle ngDefaultControl value=null [disabled]="!selectableNull">{{ descriptionList[2].description }}</mat-button-toggle>
</mat-button-toggle-group>
Run Code Online (Sandbox Code Playgroud)
TS:
import { Description } from './../core/models/description';
import { Component, ViewEncapsulation, forwardRef, Input, OnInit } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
export const NULLABLE_BOOL_VALUE_ACCESSOR: any = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => NullableBoolComponent),
multi: true
}; …Run Code Online (Sandbox Code Playgroud) I am trying to select a few words from the textarea and create bootstrap chips.
I am able to create the chips for selected words. I am trying to highlight the selected words with different background colors.
export class SearchComponent implements OnInit {
constructor() { }
selectedText = [];
regexFromMyArray: RegExp;
// tslint:disable-next-line:typedef
showSelectedText() {
let text = '';
if (window.getSelection) {
text = window.getSelection().toString();
if (text) {
// console.log(this.selectedText.includes(text));
if (this.selectedText.includes(text) === false)
{
this.selectedText.push(text);
this.regexFromMyArray = new RegExp(this.selectedText.join('|'), …Run Code Online (Sandbox Code Playgroud) angular ×10
angular8 ×10
javascript ×3
angular5 ×1
angular6 ×1
html ×1
textarea ×1
typescript ×1