<a href="#" class="secondary-content"> because href=&#34;#&#34; not direct me to the right page

时间:2018-09-09 19:18:43

标签: html collections materialize

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>

1 个答案:

答案 0 :(得分:0)

在URL中使用somedomain.com/some/path/page#domId可使浏览器向下滚动到元素<someelement id=domId>。通常用于在内容较长的页面上制作滚动锚。看起来您滥用它。我不确定为什么会为您“打开任何东西”