Skip to content

How does the property directive work? #111

@mj026

Description

@mj026

When I create a simplified example of the example on the Creating an Element documentation page:

import { Slim } from 'slim-js';
import 'slim-js/property-directive';


Slim.element(
  'my-greeting',
  /*html*/ `
    <h1>Hello, {{this.who}}!</h1>
  `,
  class MyGreeting extends Slim {
    constructor(who) {
      super()
      this.who = who;
    }
  }
);

Slim.element(
  'my-app',
  /*html*/ `
  <my-greeting .who="{{this.who}}">
  </my-greeting>
  `,
  class MyApp extends Slim {
    who = "I am the one and only"
  }
);

I expect that this.who will be set with the .who property, but whatever I do, it stays undefined.

I guess I don't understand the concept of the .who property, could you explain how this works?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions