When I checked the slide toggle it should work as expected. But when I try to uncheck it there is a confirmation window asking if you are sure. When I click cancel in that confirmation window, still the toggle changes to unchecked, which shouldn't happen. It should stay in the same state.
Here is my Html and TS Code
// html
<mat-slide-toggle
(change)="change($event)" [checked]="isChecked()" >
To-pay
</mat-slide-toggle>
Run Code Online (Sandbox Code Playgroud)
TS code:
// ts
change(e) {
if(this.checked) {
if(confirm("Are you sure")) {
console.log("toggle") …Run Code Online (Sandbox Code Playgroud) 我第一次尝试 Angular 5 单元测试。虽然我已经创建了应用程序然后决定在其中运行测试。但我收到这些错误:
AppComponent should create the app
AppComponent should have as title 'app'
AppComponent should render title in a h1 tag
GalleryComponent should create
UploadComponent should create
Run Code Online (Sandbox Code Playgroud)
和错误详细信息,如:
Failed: Template parse errors:
'app-upload' is not a known element:
1. If 'app-upload' is an Angular component, then verify that it is part of this module.
2. If 'app-upload' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. (" class="row">
<div class="col-md-3" …Run Code Online (Sandbox Code Playgroud)