为什么我不能使用Angular将此图像作为链接?

时间:2021-02-19 21:00:43

I have the following in my Angular view:

我在Angular视图中有以下内容:

    <a ui-sref="mystate({'stateParam1': 99, 'stateParam1': 98})" ng-bind="myCtrl.something.something.username">
    </a>

    <img ng-src="http://www.gravatar.com/avatar/{{myCtrl.something.something.md5Email}}"/>

It works perfectly. I see a link (for my username), followed by a nice Gravatar image of myself.

它完美地运作。我看到一个链接(对于我的用户名),然后是我自己的一个很好的Gravatar图像。

But I actually want my image and my username to both be in the body of the link. How can I do that? I tried the following but it only showed my username, not the image:

但我实际上希望我的图像和用户名都在链接的正文中。我怎样才能做到这一点?我尝试了以下但它只显示了我的用户名,而不是图像:

    <a ui-sref="mystate({'stateParam1': 99, 'stateParam1': 98})" ng-bind="myCtrl.something.something.username"> 
      <img ng-src="http://www.gravatar.com/avatar/{{myCtrl.something.something.md5Email}}"/>
    </a>

1 个解决方案

#1


0  

It seems that ng-bing changes entire text in a tag. So what is contained in enclosing a tag, that is changing with model from ng-bind which is changed to text. I think that Angular takes <a>xx</a> and sets it to variable.

似乎ng-bing会更改标签中的整个文本。那么封装一个标签所包含的内容就是随着ng-bind中的模型而改变,该模型被改为文本。我认为Angular需要 xx 并将其设置为变量。

var c = xx;
c = ng-bind
<a>c</a>

So in result we have new variable with data from ng-bind.

所以在结果中我们有来自ng-bind的数据的新变量。

Could You use you img inside ng-bind?

你可以在ng-bind中使用img吗?

#1


0  

It seems that ng-bing changes entire text in a tag. So what is contained in enclosing a tag, that is changing with model from ng-bind which is changed to text. I think that Angular takes <a>xx</a> and sets it to variable.

似乎ng-bing会更改标签中的整个文本。那么封装一个标签所包含的内容就是随着ng-bind中的模型而改变,该模型被改为文本。我认为Angular需要 xx 并将其设置为变量。

var c = xx;
c = ng-bind
<a>c</a>

So in result we have new variable with data from ng-bind.

所以在结果中我们有来自ng-bind的数据的新变量。

Could You use you img inside ng-bind?

你可以在ng-bind中使用img吗?