我在我的应用程序中使用ngx-webcam来使用网络摄像头捕获图像.我在app.module.ts中有导入库,也在我的视图中,但它给了我这个错误'webcam'不是一个已知的元素.如果在app.component html中使用网络摄像头标签,它工作正常,但我想在单独的视图中使用它.这是我的代码
import {WebcamImage} from 'ngx-webcam';
export class CreateMemberComponent implements OnInit {
private trigger: Subject<void> = new Subject<void>();
// latest snapshot
public webcamImage: WebcamImage = null;
public triggerSnapshot(): void {
this.seconds = 3;
this.trigger.next();
this.seconds = null;
}
public handleImage(webcamImage: WebcamImage): void {
console.log('received webcam image', webcamImage);
this.webcamImage = webcamImage;
}
public get triggerObservable(): Observable<void> {
return this.trigger.asObservable();
}
Run Code Online (Sandbox Code Playgroud)
这是我的HTML代码
<div class="col-sm-4">
<div style="text-align:center">
<div>
<p>{{seconds}}</p>
<webcam [trigger]="triggerObservable" (imageCapture)="handleImage($event)"></webcam>
<br/>
<button id="snapshotBtn" (click)="triggerSnapshot();">Take A Snapshot</button>
</div>
</div>
<div class="snapshot" *ngIf="webcamImage"> …Run Code Online (Sandbox Code Playgroud) 我带来了一个方法,它接受三个bool参数并返回一个字符串值.例如,我在表列中保存0,1,2.我有三个布尔变量isView,isAddUpdate和isDelete.当isView被true然后保存只有0,如果isView和isAddUpdate是真正的比节省0.1,如果所有的人都为真比保存0,1,2.
这是我的代码.请建议我更好的方法来实现这一目标.
public string getActions(bool isView, bool isAddupdate, bool isDelete)
{
try
{
var _val = "";
if (isView && isAddupdate && isDelete)
_val = "0,1,2";
if (isView && isAddupdate && !isDelete)
_val = "0,1";
if (isView && !isAddupdate && !isDelete)
_val = "0";
if (!isView && !isAddupdate && !isDelete)
_val = "";
if (!isView && !isAddupdate && isDelete)
_val = "2";
if (!isView && isAddupdate …Run Code Online (Sandbox Code Playgroud)