在尝试显示值Angular 4之前检查是否存在值

时间:2017-10-10 01:53:50

标签: angular

我正在使用Angular 4的项目。

我正在使用这样的代码:

[ubuntu ~]chmod 600 mount_point/home/ubuntu/.ssh/authorized_keys
[ubuntu ~]chmod 700 mount_point/home/ubuntu/.ssh
[ubuntu ~]chmod 700 mount_point/home/ubuntu

要显示json的一些结果,我会收到请求。

问题是我的BDD构造不好,有时没有位置。一旦值出现问题,结果的其余部分就会停止显示,这有点烦人。

有没有办法检查值是否存在,如果是这种情况,让角度显示它。我尝试使用ngIf,但遇到了与角度相同的问题,试着查看是否有值,如果没有停止ngfor。

你可以在这里看到问题:http://yunomusic.com/page-search-event(尝试使用paris作为城市广告向下滚动,你会看到: problem screenshot

我从控制台得到的错误:

<div *ngFor="let item of results">
 <p> {{item.location.city}} </p>
 <p> {{item.location.country}} </p>
</div>

angular尝试读取组件城市,但在我的BDD中的某些元素上我没有。我需要先检查一下。

提前致谢!

2 个答案:

答案 0 :(得分:5)

在这种情况下,更好的解决方案是使用 FileNotFoundException 而不使用 java -jar "E:\IdeaProjects\Encryption\out\artifacts\Encryption_jar2\DecryptContext.jar" "%1"

private String encodeBase64(String s) {
    return new String(Base64.getEncoder().encode(s.getBytes()));
}

答案 1 :(得分:2)

将* ngIf =“item.location”添加到您的p标记