我有一点问题.
我有app和Ido这个角6,我正在使用儿童路线
像这样
{
path:'pages', component:DatePagesComponent,
children : [
{path:'404', component:Error404Component},
{path:'500', component:Error500Component}
]
}
Run Code Online (Sandbox Code Playgroud)
我的HTML看起来像
<li [routerLinkActive]="['active']"><a [routerLink]="['/pages/404']">404</a></li>
<li [routerLinkActive]="['active']"><a [routerLink]="['/pages/500']">500</a></li>
Run Code Online (Sandbox Code Playgroud)
并且它使用url精确加载路由但总是加载到此 component:DatePagesComponent
如果我点击404比页面网址更改但不更改组件路由器
而我正在写作
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)
进入我的app.components.html档案
你能告诉我这是什么问题以及如何解决它.
我是Angular的新手,想从简单的学习入手。
我目前正在开发一个表单,并具有div,我需要在选择用户时进行切换。我需要创建Angular 6组件来创建这样的切换功能吗?
如何进行切换-是否使用组件(如果可能)?
谢谢
我正在使用Angular 6和Angular Material.当我单击编辑按钮时,将在选择中初始化辅助,SSC和男性值.但我无法做到这一点.我只能在单击"编辑"按钮后在下拉列表中显示"男性"值.所以我想在下拉列表中显示所有值,并为动态选择传递对象.谢谢.
我的代码链接在这里:stackblitz链接
因此,我正在处理的项目存在一些问题-一切运行正常,但我尝试取消对poly9.x和IE9的polyfill.ts中的import语句的注释。我对所有注释均未注释并运行npm install --save classlist.js和npm安装--save web-animations-js。一切仍然在chrome上构建和运行,但是仍然不能在IE11上运行,这种行为背后的任何想法是什么?它以IE11上的有角徽标打开,但只有一个空白屏幕。
我错过了什么吗?我已经在互联网上搜索了一下,但毫无用处。
我找到了类似的帖子,但没有找到合适的答案。(例如,Angular 5在IE9中不起作用“ Internet Explorer无法显示该网页”)
找到其他帖子:
angular 5应用程序在边缘上运行,但在ie11上失败
也
尝试添加到index.html:<meta http-equiv =“ X-UA-Compatible” content =“ IE = edge” />(添加了要显示的空间)
尝试添加到index.html:
并导入“ core-js / client / shim”;到polyfill.ts
Polyfill.ts:
import "core-js/es7/reflect";
import "zone.js/dist/zone";
/* IE9, IE10 and IE11 */
import "core-js/es6/array";
import "core-js/es6/date";
import "core-js/es6/function";
import "core-js/es6/map";
import "core-js/es6/math";
import "core-js/es6/number";
import "core-js/es6/object";
import "core-js/es6/parse-float";
import "core-js/es6/parse-int";
import "core-js/es6/regexp";
import "core-js/es6/set";
import "core-js/es6/string";
import "core-js/es6/symbol";
import "core-js/es6/weak-map";
/* IE10 and IE11 for NgClass …Run Code Online (Sandbox Code Playgroud) 我有一个Angular 6响应式表单,试图用正则表达式模式验证密码,但是它不起作用。
<div class="form-group">
<label for="password">Password</label>
<input type="password" formControlName="password" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.password.errors }"
/>
<div *ngIf="submitted && f.password.errors" class="invalid-feedback">
<div *ngIf="f.password.errors.required">Required</div>
<div *ngIf="f.password.errors.pattern">Not valid</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在使用的正则表达式是这样的:
ngOnInit() {
this.registerForm = this.formBuilder.group({
password: ['', [Validators.required, Validators.pattern('^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$')]],
});
}
Run Code Online (Sandbox Code Playgroud)
无论我输入什么密码,都会在用户界面中收到错误消息 Not valid
知道我在做什么错吗?
angular-validation angular angular-reactive-forms angular6 angular-validator
我在我的方法中使用重置时收到错误.我想保存更改后重置表单但我收到此错误:
这是我的方法:
@ViewChild('editFrom')
editForm: NgForm;
constructor(
private route: ActivatedRoute,
private alertify: AlertifyService
) {}
ngOnInit() {
}
updateUser() {
console.log(this.user);
this.alertify.success('Profile Updated Successfully');
this.editForm.reset(this.user);
}
}
Run Code Online (Sandbox Code Playgroud)
这个Html表单:
<form #editForm="ngForm" id="editForm" (ngSubmit)="updateUser()">
<h4>Description</h4>
<textarea name="introduction" rows="6" class="form-control" [(ngModel)]="user.introduction"></textarea>
<h4>Looking For</h4>
<textarea name="lookingFor" rows="6" class="form-control" [(ngModel)]="user.lookingFor"></textarea>
<h4>Interest </h4>
<textarea name="interests" rows="6" class="form-control" [(ngModel)]="user.interest"></textarea>
<h4>Location Details:</h4>
<div class="form-inline">
<label for="city">City:</label>
<input class="form-control" type="text" name="city" [(ngModel)]="user.city">
<label for="country">Country:</label>
<input class="form-control" type="text" name="country" [(ngModel)]="user.country">
</div>
</form>
Run Code Online (Sandbox Code Playgroud) 实际上,我想知道角度版本的实际差异-最近发布的Beta版本的8和7。
我进行了相同的研究,但无法理解这些版本的确切差异–角度7和角度8。
我从https://mean.io生成了一个项目。但是我不确定(.env和.env.example)与(environment.ts和environment.prod.ts)之间有什么区别。
我应该将所有配置数据,机密和密钥存储在哪里?
我有此映射用户* ------------------------ 1职业。我想修改一个用户。所以我从中选择一个list-users.component.html,我将被重定向到modify-user.component.html。
以下是必需的文件:
Modify-user.component.html
<form [formGroup]="editForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="name">Name</label>
<input type="text" formControlName="name" placeholder="Name" name="name" class="form-control" id="name">
</div>
<div *ngFor='let pro of professions; let i = index'>
<label>
<input type="radio"
id="pro.id"
checked="pro.selected"
name="pro"
[(ngModel)]="this.editForm.pro"
(change)='radioChecked(pro.id, i)'
[value]="pro.libelle">
<span></span>
<span class="check"></span>
<span class="box"></span>
{{pro.libelle}}
</label>
</div>
<p>==> {{selectedProfessionRadio}}</p>
<button class="btn btn-success">Update</button>
</form>
Run Code Online (Sandbox Code Playgroud)
Modify-user.component.ts
export class ModifyUserComponent implements OnInit
{
private selectedProfessionRadio;
professionLib: string;
editForm: FormGroup;
usrId: String;
professions: Profession[] =
[
{id: 1, libelle: "Engineer", …Run Code Online (Sandbox Code Playgroud)