# .gjs ファイルでモバイル表示用の異なるコンテンツを表示する

**URL:** https://meta.discourse.org/t/showing-different-content-for-mobile-view-in-a-gjs-file/374657
**Category:** Development
**Tags:** mobile, ember
**Created:** [2025 年 7 月 17 日午後 3:39 UTC](https://meta.discourse.org/t/showing-different-content-for-mobile-view-in-a-gjs-file/374657 "2025-07-17T15:39:55Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2025 年 7 月 17 日午後 11:38 UTC](https://meta.discourse.org/t/showing-different-content-for-mobile-view-in-a-gjs-file/374657/5 "2025-07-17T23:38:01Z")

</div>

お好みで、`renderInOutlet` 呼び出し内にクラス全体を配置することもできます。

```gjs
import { apiInitializer } from "discourse/lib/api";
import Component from "@glimmer/component";
import { service } from "@ember/service";

export default apiInitializer((api) => {
  api.renderInOutlet(
    "composer-after-save-or-cancel",
    class extends Component {
      @service site;

      <template>
        {{#if this.site.mobileView}}
          Mobile!
        {{else}}
          Normal!
        {{/if}}
      </template>
    }
  );
});

```

しかし、`.lookup()` ソリューションも妥当です。結局のところ、`@service` は舞台裏で同じことを行っていますからね 👌

---

_[View the full topic](https://meta.discourse.org/t/showing-different-content-for-mobile-view-in-a-gjs-file/374657)._
