在ng-repeat中更改angularJS中的类

时间:2017-09-13 07:10:02

标签: angularjs cordova ionic-framework ionic-v1

我有两个css分类public void HideMessageDialog () { this.Dispatcher.Invoke( async () =>{ BaseMetroDialog dialogBeingShow = await this.GetCurrentDialogAsync<BaseMetroDialog>(); //Hide Current Single Dialog if(dialogBeingShow != null) await this.HideMetroDialogAsync(dialogBeingShow); //Or Hide All Dialogs while (dialogBeingShow != null) { await this.HideMetroDialogAsync(dialogBeingShow); dialogBeingShow = await this.GetCurrentDialogAsync<BaseMetroDialog>(); } } ); } triangle

triangleo

所以如果chatdata.usrId == 123 class应为<div class="triangle" ng-repeat="chatdata in chats"> <p>{{chatdata.msg}}</p> <p> {{chatdata.time}}</p> </div> else triangle

1 个答案:

答案 0 :(得分:3)

您只需使用ng-class

即可
<div ng-class="chatdata.usrId === 123 ? 'triangle' : 'triangleo'" ng-repeat="chatdata in chats">
   <p>{{chatdata.msg}}</p>
   <p> {{chatdata.time}}</p>
</div>