我是 Angular 6 的新手,这里我有 formControl,而不是根据业务需求使用 FormGroup。
应用程序组件.html
<button
class="col-sm-12"
[disabled]="comittee_Member_Name.invalid && comittee_Member_Number.invalid && comittee_Type.invalid && comittee_Member_Position.invalid && comittee_Member_Status.invalid"
>
Save
</button>
Run Code Online (Sandbox Code Playgroud)
在这里,如果formControl 中的任何一个无效,我想禁用该按钮。但就我而言,它仅验证第一个表单控件(comittee_Member_Name)。
应用程序组件.ts
comittee_Member_Name =new FormControl();
comittee_Member_Number = new FormControl();
comittee_Type = new FormControl();
comittee_Member_Position = new FormControl();
comittee_Member_Status = new FormControl();
Run Code Online (Sandbox Code Playgroud)
谁能帮我解决这个问题。
我从后端收到一组对象,其中包含文本作为字段之一。我希望能够编辑该文本。
到目前为止我有这样的事情:
<div *ngFor="let speech of speeches; index as i">
<div class="card">
<div class="card-header">
<div class="row">
//some other input fields
<div class="card-body">
<ckeditor [(ngModel)]=speech.content
[editor]="editor"
name={{i}}
required
[config]="ckeConfig"
debounce="500"
(change)="onChange($event)">
</ckeditor>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
当演讲数组达到 30-40 左右时,它可以正常工作,但对于更大的数组,它甚至会导致浏览器崩溃。
有人遇到过这个问题并解决了吗?
我有一个注册和登录页面。因此,对于注册表单,我使用了表单验证器模式匹配。
this.registerForm = this.formBuilder.group({
firstName: ['', Validators.required],
emailId: ['', [Validators.required, Validators.pattern('^[a-zA-Z0-
9_.+-]+@christmas.com')]],
//password: ['', [Validators.required, Validators.minLength(6)]],
password: ['', [Validators.required]
})
Run Code Online (Sandbox Code Playgroud)
我从这里获取数据到nodejs并存储在mysql数据库中。现在,对于电子邮件 ID,我需要使其忽略大小写。我这里该怎么办呢。有人可以建议我一种方法吗?
HTML5
<div class="row rating" style="float:right;">
<span class="fa fa-star" name="val1" [(ngModel)]="data.val1"></span>
</div>
Run Code Online (Sandbox Code Playgroud)
TS
data = {
val1 = ''
}
Run Code Online (Sandbox Code Playgroud)
注意:我需要一个唯一的名称。我想使用星级系统。我只想知道名字。
我正在制作角度应用程序,并且我有一个空数组,例如,
users: any = [];
Run Code Online (Sandbox Code Playgroud)
然后我进行服务调用以ngOnInit将数据存储到users数组中,例如,
ngOnInit() {
//Getting the data from json
this.httpClient.get('https://api.myjson.com/bins/n5p2m').subscribe((response: any) => {
console.log("response", response.data);
response.data.forEach(element => {
//Pusing the data to users array
this.users.push(element);
});
})
//Trying to get the complete array after push of the element from the service response data
console.log("users array", this.users);
//But it shows empty array
}
Run Code Online (Sandbox Code Playgroud)
但我无法获取数据,console.log("users array", this.users);因为服务呼叫造成了延迟。
如何将数据推送到this.users服务中,当我们在服务外部调用时,它应该具有填充的数据,而不是像现在这样为空。
还做了一个关于它的工作 stackblitz https://stackblitz.com/edit/angular-q3yphw
请查看具有当前结果的控制台。
当前结果是console.log("users array", this.users);空数组[] …
当尝试使用 HTML 文件更新网格表时,我收到此错误消息。
在这里,我使用了静态数据来显示表格,并从显示 primeng 表的其他组件导入,并且我添加了一个更新按钮,该按钮具有重定向到另一个页面以更新数据的功能。
该问题出现在 HTML 文件的第一行中,即;[formGroup]="我的车辆"
我尝试使用不同的表单组名称进行检查,但问题仍然相同。
import { Component, OnInit } from '@angular/core';
import {Router, ActivatedRoute, Params} from '@angular/router';
import { FormBuilder, FormGroup } from '@angular/forms';
@Component({
selector: 'app-crud',
templateUrl: './crud.component.html',
})
export class CrudComponent implements OnInit {
myvehicle: FormGroup;
display: boolean;
id: number;
vin: any;
year: number;
brand: string;
color: string;
vehicle: any;
Data: any;
constructor(private activatedRoute: ActivatedRoute, private fb: FormBuilder) {
}
ngOnInit() {
this.myvehicle = this.fb.group({
vin: [''],
year: [''],
brand: [''],
color: …Run Code Online (Sandbox Code Playgroud)我使用的 Angular Popup 组件如下(在线示例):
<popup>
<anchor>
Menu
</anchor>
<window>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</window>
</popup>
Run Code Online (Sandbox Code Playgroud)
组件模板是:
<a class="anchor" (click)="toggle()">
<ng-content select="anchor"></ng-content>
</a>
<div class="window" [hidden]="!active">
<ng-content select="window"></ng-content>
</div>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Template parse errors: 'anchor' is not a known element:
1. If 'anchor' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
Run Code Online (Sandbox Code Playgroud)
弹出模块已经有 NO_ERRORS_SCHEMA:
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core'; …Run Code Online (Sandbox Code Playgroud) 我正在尝试将ng2-pdf-viewer我的 Angular 6 应用程序与 webpack 集成。
我已按照此处添加模块的说明进行操作;
因此,该条目被添加到我的包.json中,如下所示;
{
"name": "myApp",
"private": true,
"version": "0.0.0",
"scripts": {
"start": "concurrently \"webpack-dev-server --env=dev --open --hot --inline --port 8080\" \"dotnet run\" ",
"node-sass": "npm rebuild node-sass",
"webpack-dev": "webpack --env=dev",
"webpack-production": "webpack --env=prod",
"build-dev": "npm run webpack-dev",
"build-production": "npm run webpack-production",
"watch-webpack-dev": "webpack --env=dev --watch --color",
"watch-webpack-production": "npm run build-production --watch --color",
"publish-for-iis": "npm run build-production && dotnet publish -c Release",
"test": "karma start",
"test-ci": "karma start --single-run --browsers ChromeHeadless",
"lint": …Run Code Online (Sandbox Code Playgroud) 如何仅在开发模式下加载某些路由。当我在启用生产模式的情况下构建时,我希望禁用这些路由。
有人对如何实现此功能有什么好的建议吗?例如,如果处于开发模式,则隐藏下面的route2组件。
const routes: Routes = [
{
path: '',
component: AdminComponent,
canActivate: [AuthGuard],
runGuardsAndResolvers: 'always',
data: { allowedRoles: ['Role1','Role2'] },
children: [
{
path: '',
redirectTo: 'dashboard/main',
pathMatch: 'full'
},
{
path: 'route2',
loadChildren: './theme/route2/route2.module#route2Module'
}
]
}
Run Code Online (Sandbox Code Playgroud) 我尝试在 Angular 6 打字稿中使用节点模块。
第一个:npm i Shortid
In TypeScript class:
import { shortid } from 'shortid';
let Uid = shortid.generate();
Run Code Online (Sandbox Code Playgroud)
但我收到错误“找不到函数generate()”;
如何正确使用?