【发布时间】:2020-04-03 20:02:57
【问题描述】:
问题是:
如何使 html 或 ts 上的链接正常工作?
我需要一些指向我的应用程序外部页面的链接。我有用户个人资料和个人资料我有指向该用户社交帐户的链接(例如instagram.com/sisterofclara)但在此表单上:
<div class="col-md-12" *ngFor="let currentAccountObject of user.userContact.accounts">
<div class="margin-10-px" >
<div class="col-md-1 font-bold">
<img[src]="getIcon(currentAccountObject.socialAccountType)">
</div>
<div class="col-md-9 font-bold"> {{currentAccountObject.login}}
</div>
</div>
</div>
我无处可去,因为当我点击链接时,我的链接总是在短语前有localhost:3000。总是。
我尝试使用 uri 作为参数在 angular 上创建 click 函数,函数看起来像这样:
public goToProfile(url) {
window.location.href = url;
}
我通过点击尝试了它,我尝试了href={{person.link}},我尝试了这个功能,我也尝试了location.replace(uri),但没有任何效果(因为添加了我的localhost 开头)。为什么?
编辑:这是html:
<div class="row col-md-12 contact">
<div *ngIf="contactTabEditable==false">
<div class="col-md-12 ro-label" align="left">Social media:</div>
<div class="col-md-10 social-media">
<div>
<div class="col-md-12" *ngFor="let currentAccountObject of user.userContact.accounts">
<div class="margin-10-px" >
<div class="col-md-1 font-bold"><img [src]="getIcon(currentAccountObject.socialAccountType)"></div>
<div *ngIf="currentAccountObject.link" class="col-md-9 font-bold">
<a (click)="goToProfile(currentAccountObject.link)"> {{currentAccountObject.login}} </a>
</div>
<!-- <div *ngIf="!showClickableAccount" class="col-md-9 font-bold"> {{currentAccountObject.login}}</div> -->
</div>
</div>
</div>
</div>
</div>
</div>
【问题讨论】:
标签: javascript html css angular typescript