我需要声明这个变量来输入任何?这显示在我的HTML模板中的可视代码编辑器中.
产品form.component.html
<div class="row">
<div class="col-md-6">
<form #form="ngForm" (ngSubmit)="save(form.value)">
<div class="form-group">
<label for="title">Title</label>
<input #title="ngModel" [(ngModel)]="product.title" name="title" id="title" type="text" class="form-control" required>
<div class="alert alert-danger" *ngIf="title.touched && title.invalid">
Title is required.
</div>
</div>
<div class="form-group">
<label for="price">Price</label>
<div class="input-group">
<span class="input-group-addon">$</span>
<input #price="ngModel" ngModel [(ngModel)]="product.price" name="price" id="price" type="number" class="form-control" required [min]="0">
</div>
<div class="alert alert-danger" *ngIf="price.touched && price.invalid">
<div *ngIf="price.errors.required">Price is required.</div>
<div *ngIf="price.errors.min">Price should be 0 or higher.</div>
</div>
</div>
<div class="form-group">
<label for="category">Category</label>
<select #category="ngModel" ngModel [(ngModel)]="product.category" name="category" id="category" …
Run Code Online (Sandbox Code Playgroud) 在我缓慢地理解Angular等问题时,我的Visual Studio代码编辑器出现了一个错误,该错误似乎并不影响应用程序功能。
当我将鼠标悬停在HTML模板中的变量上时,会收到此弹出窗口
我的html模板到处都是与产品对象product.ETC相关的所有错误。
有人可以指出我正确的方向,以了解如何解密。
product-form.component.html
<div class="row">
<div class="col-md-6">
<form #form="ngForm" (ngSubmit)="save(form.value)">
<div class="form-group">
<label for="title">Title</label>
<input #title="ngModel" [(ngModel)]="product.title" name="title" id="title" type="text" class="form-control" required>
<div class="alert alert-danger" *ngIf="title.touched && title.invalid">
Title is required.
</div>
</div>
<div class="form-group">
<label for="price">Price</label>
<div class="input-group">
<span class="input-group-addon">$</span>
<input #price="ngModel" ngModel [(ngModel)]="product.price" name="price" id="price" type="number" class="form-control" required [min]="0">
</div>
<div class="alert alert-danger" *ngIf="price.touched && price.invalid">
<div *ngIf="price.errors.required">Price is required.</div>
<div *ngIf="price.errors.min">Price should be 0 or higher.</div>
</div>
</div>
<div class="form-group">
<label for="category">Category</label>
<select #category="ngModel" …
Run Code Online (Sandbox Code Playgroud) 尝试使用最新版本的Firebase和Angular.我想要实现的总体概念是管理员身份验证.我已经实现了登录注销功能.我已使用UID将googleAuth登录用户保存到数据库.现在我要做的是将一些页面限制为登录和管理员.所以我已经将isAdmin:true指定为存储在数据库中的用户对象中的值.基本上我想查看用户是否为admin并为路由器参数返回true或false.我一直在使用Angular和Firebase.我认为自己是初学者.我不太明白如何从AngularFire2 4 - > AngularFire 5迁移.我得到的当前错误是TS2345:
ERROR in src/app/admin-auth-guard.service.ts(15,38): error TS2345: Argument of type '(user: User) => AngularFireObject<AppUser>' is not assignable to parameter of type '(value: User, index: number) => ObservableInput<{}>'.
Type 'AngularFireObject<AppUser>' is not assignable to type 'ObservableInput<{}>'.
Type 'AngularFireObject<AppUser>' is not assignable to type 'ArrayLike<{}>'.
Property 'length' is missing in type 'AngularFireObject<AppUser>'.
Run Code Online (Sandbox Code Playgroud)
从我认为我理解get函数返回一个Object,但错误是期望一个可观察的.我所知道的关于可观察物的是你可以订阅它们而你应该销毁它们......
我需要使用当前登录的用户ID来查询数据库并返回与uid匹配的用户对象,然后检查isAdmin是true还是false.然后将其返回到路径参数,以便我可以将页面限制为Authenticated和Admin.
请指出我正确的方向.
管理员认证 - guard.service.ts
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { AuthService } from './auth.service';
import { …
Run Code Online (Sandbox Code Playgroud)