小编leg*_*iom的帖子

如何将元素的高度设置为与其宽度相同并在窗口调整大小时保持尺寸比例?

我试图将元素的高度设置为其宽度。它应该根据网络浏览器分辨率的变化自动缩放/保持大小比例。有没有办法只用 html 模板来做到这一点?就像是:

<div class="tile" #square [ngStyle]="{'height.px': square.width}">
Run Code Online (Sandbox Code Playgroud)

javascript css height width angular

2
推荐指数
1
解决办法
2714
查看次数

Angular 2+无法读取未定义的属性"id"

我有一个奇怪的错误,我无法找出原因.根据:来自路由的id,我正在获取表privateLessons,然后搜索具有正确id的一个对象并显示到我的模板中.最后,我得到了我想要的效果,数据显示正确,但我在控制台中得到两个相同的错误:

ERROR TypeError: Cannot read property 'id' of undefined
at Object.eval [as updateRenderer] (DetailedAnnouncementComponent.html:3)
at Object.debugUpdateRenderer [as updateRenderer] (core.es5.js:13094)
at checkAndUpdateView (core.es5.js:12241)
at callViewAction (core.es5.js:12601)
at execComponentViewsAction (core.es5.js:12533)
at checkAndUpdateView (core.es5.js:12242)
at callViewAction (core.es5.js:12601)
at execEmbeddedViewsAction (core.es5.js:12559)
at checkAndUpdateView (core.es5.js:12237)
at callViewAction (core.es5.js:12601)
Run Code Online (Sandbox Code Playgroud)

如何解决?

详细-announcement.html

  <div class="detailed-announcement">
    {{ privateLesson.id }}
    {{ privateLesson.subject }}
    {{ privateLesson.category }}
    {{ privateLesson.price }}
    {{ privateLesson.level }}
    {{ privateLesson.voivodeship }}
    {{ privateLesson.city }}
    {{ privateLesson.place }}
    {{ privateLesson.description }}
    {{ privateLesson.author }}
  </div>
Run Code Online (Sandbox Code Playgroud)

详细-announcement.tmp

import …
Run Code Online (Sandbox Code Playgroud)

angular

2
推荐指数
1
解决办法
2015
查看次数

标签 统计

angular ×2

css ×1

height ×1

javascript ×1

width ×1