# Using ViewSlot causing an error

**URL:** <https://discourse.aurelia.io/t/using-viewslot-causing-an-error/5505>\
**Category:** Help Requests\
**Created:** [July 29, 2024, 3:22pm UTC](https://discourse.aurelia.io/t/using-viewslot-causing-an-error/5505 "2024-07-29T15:22:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vladyn](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/vladyn/32/2473_2.png) [@vladyn](https://discourse.aurelia.io/u/vladyn)\
**Post date:** [July 29, 2024, 3:22pm UTC](https://discourse.aurelia.io/t/using-viewslot-causing-an-error/5505/1 "2024-07-29T15:22:05Z")

</div>

Hello guys,  
what I’m trying is

```auto
import { ViewSlot } from 'aurelia-framework';

export class ContextMenuRenderer {
  visible = false;
  items = [];
  viewSlot = null;

  constructor() {
  }

  render() {
    const container = document.createElement('div');
    container.className = 'context-menu-container';
    const slot = document
    document.body.appendChild(container);
    this.contextMenu = document.createElement('context-menu');
    this.contextMenu.setAttribute('visible.bind', 'visible');
    this.contextMenu.setAttribute('items.bind', 'items');
    this.viewSlot = new ViewSlot(container, true);
    
    this.viewSlot.add(this.contextMenu);
  }
}

```

What I’m doing wrong here as in the console I’m getting

```auto
aurelia-templating.js:1361 Uncaught (in promise) TypeError: view.appendNodesTo is not a function
    at push.960.ViewSlot.add (aurelia-templating.js:1361:1)
    at ContextMenuRenderer.render (context-menu-renderer.js:23:1)
    at App.attached (app.js:13:1)
    at push.960.Controller.attached (aurelia-templating.js:2888:1)
    at push.960.View.attached (aurelia-templating.js:1204:1)
    at push.960.ViewSlot.attached (aurelia-templating.js:1516:1)
    at aurelia-framework.js:393:1

```

---

<div class="post-metadata">

**Author:** ![bigopon](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/bigopon/32/18_2.png) [@bigopon](https://discourse.aurelia.io/u/bigopon)\
**Post date:** [July 30, 2024, 10:55pm UTC](https://discourse.aurelia.io/t/using-viewslot-causing-an-error/5505/2 "2024-07-30T22:55:32Z")

</div>

`ViewSlot` can only add `View`, or `ViewSlot` instances. You are trying to add an element hence the error.
