Javascript 如何备课?
我正在我的ionic应用程序中集成聊天,我想在数据库中显示message.userId后面的消息 我有两个人被称为myId(我)和otherId(另一个人)。这两个变量在my.js文件中都被称为变量 我使用以下代码:Javascript 如何备课?,javascript,html,angularjs,ionic-framework,firebase-realtime-database,Javascript,Html,Angularjs,Ionic Framework,Firebase Realtime Database,我正在我的ionic应用程序中集成聊天,我想在数据库中显示message.userId后面的消息 我有两个人被称为myId(我)和otherId(另一个人)。这两个变量在my.js文件中都被称为变量 我使用以下代码: <li ng-repeat="message in messages" ng-class="{self: message.userId = myId, other: message.userId = otherId}"> <!--
<li ng-repeat="message in messages" ng-class="{self: message.userId = myId, other: message.userId = otherId}">
<!-- *avatar / avatar image -->
<div class="avatar">
<img src="img/82.jpg">
</div>
<!-- *msg / messages -->
<div class="msg">
<p>{{ message.text }}</p>
<time>
<i class="icon ion-ios-clock-outline"></i>
{{message.time}}
</time>
</div>
</li>
有什么想法吗?您正在使用
ng类中的单个等式=
:
<li ng-class="{self: message.userId = myId, other: message.userId = otherId}">
这是一项作业,不是预期的测试!使用双重或三重相等:
<li ng-class="{self: message.userId === myId, other: message.userId === otherId}">
{self:message.userId==myId,other:message.userId==otherId}
-即使是双==
也可以,但不是单=
!单个=
意味着分配,=
或==
意味着平等性测试。将其作为解决方案发布,因为:它起作用了!真不敢相信我这么累了。非常感谢。
<li ng-class="{self: message.userId === myId, other: message.userId === otherId}">