Skip to content

Add an example on how to access controller in gjs/gts templates #2183

@urbany

Description

@urbany

It would be helpful to have here an example here: https://guides.emberjs.com/v6.9.0/routing/controllers/

HEre is the current exmaple with gjs valid code, could be added to the page or replaced

<template>
  <h1>{{@model.title}}</h1>
  <h2>by {{@model.author}}</h2>

  <div class='intro'>
    {{@model.intro}}
  </div>
  <hr>

  {{#if @controller.isExpanded}}
    <button type="button" {{on "click" @controller.toggleBody}}>Hide Body</button>
    <div class="body">
      {{@model.body}}
    </div>
  {{else}}
    <button type="button" {{on "click" @controller.toggleBody}}>Show Body</button>
  {{/if}}
</template>

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions