Problem
The problems is based on the third line in the html code section.
When I click my edit button/icon i go to my front-page. I quess it because of http://localhost:xxxx/ and not http://localhost:xxxx/note有问题。例如,我尝试过href = / note /#,但是它只是重新加载了笔记页面,而没有打开辅助内容。
http://localhost:xxxx/note的HTML代码:
<div *ngIf="notes?.length > 0;else noNotes">
<ul *ngFor="let note of notes" class="collection">
<li class="collection-item"><strong>{{note.title}}: </strong> {{note.description}} <a href="#" class="secondary-content">
<i (click)="editNote($event, note)" class="fa fa-pencil"></i>
<i *ngIf="editState && noteToEdit.id == note.id" (click)="clearState()" class="fa fa-compress"></i>
</a>
<div *ngIf="editState && noteToEdit.id == note.id">
<form (ngSubmit)="updateNote(note)">
<div class="row">
<div class="input-field col s6">
<input type="text" placeholder="Add Title" [(ngModel)]="note.title" name="title">
</div>
<div class="input-field col s6">
<input type="text" placeholder="Add Description" [(ngModel)]="note.description" name="description">
</div>
<input type="submit" value="Update Note" class="btn orange">
<button (click)="deleteNote($event, note)" class="btn red">Delete Item</button>
</div>
</form>
</div>
</li>
</ul>
答案 0 :(得分:0)
在URL中使用somedomain.com/some/path/page#domId
可使浏览器向下滚动到元素<someelement id=domId>
。通常用于在内容较长的页面上制作滚动锚。看起来您滥用它。我不确定为什么会为您“打开任何东西”