我正在修复我们的 AngularJS 应用程序中的一些小问题——我遇到了下面的逻辑,它只显示一个链接。
在伪代码风格..
if (data.serviceId exists in the DOM) {
display link & populate the href from data.serviceId value
} elseif(commentReply.sender.serviceId exists in the DOM) {
display the link & populate the href from commentReply.sender.serviceId value
}
模板中的代码本身如下所示,如何修改下面的代码使其更清晰,并且我不会使用某种形式的单行第三语句来复制行?
<a ng-if="data.serviceId" ng-href="/#/profile/{{data.serviceId}}">View</a>
<a ng-if="commentReply.sender.serviceId" ng-href="/#/profile/{{commentReply.sender.serviceId}}">View</a>