小编ali*_*lia的帖子

在Angular中使用ngIf获取错误

我使用的角度,我想从一个变量,它是JSON形式.I'm能够做到这一点的显示数据*ngfor而且我希望把它检查是否msg.who =="博特"的条件我正在这样做:

<div class="UserWrapper" *ngFor="let msg of msgs" ngIf="msg.who == 'User ">
    <div class=""></div>
        <div class = "speech-bubble1 z-depth-5"><p>{{msg.msg}}</p>
            <p class="timeRight">{{msg.time}}</p>
    </div>
 </div>
Run Code Online (Sandbox Code Playgroud)

我不知道如何使用ng如果另一种方式,但这样做我得到以下错误.

ERROR Error: StaticInjectorError(AppModule)[NgForOf -> TemplateRef]: 
StaticInjectorError(Platform: core)[NgForOf -> TemplateRef]: 
NullInjectorError: No provider for TemplateRef!
Run Code Online (Sandbox Code Playgroud)

我该如何检查给定的条件

angular-ng-if angular

7
推荐指数
1
解决办法
1860
查看次数

为什么在将最终int分配给一个字节时没有错误

为什么我什么时候会收到错误

       int i=123;
       byte b=i;
Run Code Online (Sandbox Code Playgroud)

但不是在这种情况下

      final int i=123;
      byte b=i;
Run Code Online (Sandbox Code Playgroud)

java

6
推荐指数
1
解决办法
131
查看次数

标签 统计

angular ×1

angular-ng-if ×1

java ×1