我尝试使用Angular 4.0.0和Material 2构建我的第一个登录表单.但是Form不提交并触发该函数.
<form #UserLogin="ngForm" *ngIf="active" (ngSubmit)="onSubmit(UserLogin.value)">
<md-input-container>
<input mdInput [(ngModel)]="data.email" ngControl="email" name="email" placeholder="Benutzername" type="text" required>
</md-input-container>
<md-input-container>
<input mdInput [(ngModel)]="data.password" ngControl="password" name="password" placeholder="Passwort" type="password" required>
</md-input-container>
<button md-button class="submit-btn" type="submit" [disabled]="!UserLogin.form.valid">Login!</button>
Run Code Online (Sandbox Code Playgroud)
提交功能:
onSubmit(value: any) {
console.log('sdfdfg');
Object.assign(value, this.additionalData);
this.submitted = true;
this.auth.login(value).subscribe(
data => {
this.loginSuccess.emit(data);
},
error => {
for (const field in this.formErrors) {
if (this.formErrors.hasOwnProperty(field)) {
this.formErrors[field] = [];
if (this.validationMessages[field].hasOwnProperty(error.systemCode)) {
this.formErrors[field].push(this.validationMessages[field][error.systemCode]);
}
}
}
}
);
}
Run Code Online (Sandbox Code Playgroud)
当我单击登录按钮时,他不会将控制台日志输入控制台.有人有什么想法?
我完全对此错误感到困惑。我有一个非常基本的简单路由:
const routes: Routes = [
{
path: '', component: FrameDefaultComponent, pathMatch: 'full',
children: [
{path: '', component: SiteCalculatorComponent},
{path: 'site-notice', component: SiteSiteNoticeComponent}
]
},
];
Run Code Online (Sandbox Code Playgroud)
当我单击菜单菜单项中的site-notice时,如下所示:
menuEntries = [
{
title: 'Calculator',
url: '/'
},
{
title: 'Site Notice',
url: '/site-notice'
}
];
Run Code Online (Sandbox Code Playgroud)
然后我得到以下错误:
core.js:1521 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'site-notice'
Error: Cannot match any routes. URL Segment: 'site-notice'
at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:1359)
at CatchSubscriber.selector (router.js:1340)
at CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:33)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
at …Run Code Online (Sandbox Code Playgroud) 我在Angular4项目中获得了以下小代码:
<div class="divider"></div>
<ng-content select=".nav-toggle"></ng-content>
Run Code Online (Sandbox Code Playgroud)
现在,我想使分隔线仅可见,如果ng-content标签中的内容来自外部。这可能吗?我绝对找不到有关此的任何信息。
我正在用 Angular 和 ionic 编写一个信使。我想scrollToBottom在滚动到最大底部时触发该方法。因为如果有人滚动顶部查看旧消息,而合作伙伴正在发送任何消息,那么他不会每次都被踢到底部。
这是文档: https: //ionicframework.com/docs/api/content但我找不到任何可以帮助我解决这个问题的文档。