Error: Assertion Failed - The value being iterated over in #each must be an Array. Can someone please help me figure out what I'm

I am currently working on the TodoMVC tutorial for Ember and I have hit a roadblock. Specifically, I have defined 2 controllers. Here is my todos.js file:

import Ember from "ember";

export default Ember.ArrayController.extend({
    actions:{
        createTodo: function(){
            var title = this.get("newTitle");

            if(!title){
                return false;
            }
            if(!title.trim()){
                return;
            }

            var todo = this.store.createRecord("todo", {
                title: title,
                isCompleted: false
            });

            // Clear text field
            this.set('newTitle', '');

            todo.save();
        }
    }
})

And here is my todo.js file:

import Ember from "ember"

export default Ember.ObjectController.extend({
    isCompleted: function(key, value){
        var model = this.get("model");

        if(value === undefined){
            return model.get("isCompleted");
        } else {
            model.set('isCompleted', value);
            model.save();
            return value;
        }
    }.property('model','model.isCompleted')
});

Next, let me show you my routes/todos.js file:

import Ember from "ember";

export default Ember.Route.extend({
    model: function() {
        return this.store.find("todo");
    }
});

Finally, I also have todos.hbs file:

<ul id="todo-list">
    {{#each todo in model itemController="todo"}}
        <li {{bind-attr class="todo.isCompleted:completed"}}>
            {{input 
            type="checkbox"
            class="toggle"
            checked=todo.isCompleted
            }}
            <label>{{todo.title}}</label><button class="destroy"></button>
        </li>
    {{/each}}
</ul>

Everything seems to be set up correctly, but I keep encountering the following error in the console:

Uncaught Error: Assertion Failed: The value that #each loops over must be an Array. You passed todomvc-embercli@controller:array:, but it should have been an ArrayController

Can someone point out what mistake I might be making here?

Answer №1

According to a comment by turboMaCk, it appears that removing ember-disable-proxy-controllers from package.json resolves the problem.

Answer №2

A newly reported issue surfaced on the Ember GitHub page just yesterday. It appears to be a bug associated with Ember, and at this time, there isn't a known workaround available. However, it has been suggested that opting for components instead of array and item controllers could be a viable alternative (which is actually the recommended approach). Perhaps examining this provided gist from the issue may offer some insights.

If a workaround or fix is discovered in the future, I will revisit this response and provide an update. For now, I recommend steering clear of array controllers despite them being included in the tutorial. :/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Sending STATIC_URL to Javascript file in Django

What is the most effective method for transferring {{ STATIC_URL }} to JavaScript files? I am currently using django with python. Thank you in advance. Best regards. ...

changing web pages into PDF format

I need to convert HTML to PDF on a Linux system and integrate this functionality into a web application. Can you suggest any tools that are capable of doing this? Are there any other tools I should consider for this task? So far, I have attempted the foll ...

Can a jQuery object be generated from any random HTML string? For example, is it possible to create a new link variable like this: var $newlink = $('<a>new link</a>')?

I'm looking to create an object without it being attached to the dom. By passing a HTML string, I want to insert the element into the dom and still have a reference to it. ...

Tips for optimizing data retrieval from a MongoDB collection by leveraging Node.js, Mongoose, and MongoDB connections efficiently

In my scenario, I have two key collections: orders and driverResponse. The driver has the ability to either accept or decline an order, with his response being saved in the driverResponse collection. When the driver revisits the order, it is important to ...

Generating a random number to be input into the angular 2 form group index can be done by following these

One interesting feature of my form is the dynamic input field where users can easily add more fields by simply clicking on a button. These input fields are then linked to the template using ngFor, as shown below: *ngFor="let data of getTasks(myFormdata); ...

How to Show Data from the nth Position in an Array Using a Velocity Template

When customizing email templates for app dynamics, we are required to utilize velocity template 1.7 I have a health rule called ab-cd-ef-gh. The first two parts remain constant while the last two parts represent the microservice name. I am interested in d ...

Ways to switch the class of the nearest element

When an image within the .process class is clicked, I am using the following code to toggle the class of .process-info to .process--shown. The code successfully toggles the class; however, it affects all elements on the page with the class of .process-inf ...

Tips for keeping the Menu bar at the top of the page while scrolling from the middle

I came across a technique mentioned here that I wanted to implement. I used this jsfiddle link (which worked well) to create my own version http://jsfiddle.net/a2q7zk0m/1/, along with a custom menu. However, now it seems like it's not working due to a ...

Conceal the form upon submission using Angular JS

Currently trying to understand some Angular concepts and following a tutorial for practice. When I click the button below, a form is displayed. How can I hide this form once it has been submitted? Essentially, I want the form to disappear after submission ...

What is the reason the 'Add' type does not meet the 'number' constraint?

I experimented with type gymnastics using Typescript, focusing on implementing mathematical operations with numeric literals. First, I created the BuildArray type: type BuildArray< Length extends number, Ele = unknown, Arr extends unknown ...

The functionality of setTimeout in Chrome extension is malfunctioning

Greetings everyone, this is my first post here! I'm currently working on a chrome extension where I am utilizing a recursive setTimeout function. Interestingly, I've noticed that setting the timeout to 13 seconds works fine, but anything beyond ...

Whenever I refresh the page, the useEffect hook in React.js returns an empty array for the URL

When the filterOnClick function is called, it returns the necessary "fdata". Console : [[Prototype]]: Array(2) 0: {filter: 'countries', values: Array(3), search: '', checkedValue: 'india'} 1: {filter: 'states', va ...

Implementing global parameters in ui-router

Currently, I am utilizing ui-router in AngularJS as shown below: .state ('browse.category', { url: "/:category", templateUrl: "views/browseCategory.html", controller: function($stateParams, $scope) { $scope.params = $st ...

JavaScript code that generates HTML formatted mail body

var theApp = new ActiveXObject("Outlook.Application"); var theMailItem = theApp.CreateItem(0); theMailItem.To = to; theMailItem.Subject = (subject); theMailItem.CC = carbon; theMailItem.Body = (msg); theMailItem.display(); I have a JavaScript cod ...

Can you propose a different approach to creating the "word stack" that overcomes the limitations of my current method?

I am attempting to convert a set of two radio buttons into a stack of two labels, one blue and one gray, to represent the selected radio button and the unselected one. Clicking on this stack will toggle which label is blue (and consequently which radio but ...

Having Trouble with $.ajax Function in my Program

After spending three days experimenting with various methods, I'm still unable to successfully use the Javascript ajax command to send form values to a php script. Despite no errors being displayed and the scripts running smoothly, nothing is getting ...

Is it better to use Asynchronous or Synchronous request with XMLHttpRequest in the Firefox Extension for handling multiple requests

As a newcomer to developing Firefox Add-Ons, my initial project involves calling an external API in two steps: Step 1) Retrieve data from the API. Step 2) Use the data retrieved in Step 1 to make another call to the same API for additional information. ...

Having trouble with Three.js loading gltf file?

I encountered an issue while working on a project that involved using three.js with svelte. The problem arose when attempting to load a 3D model, resulting in a server response of 404 not found. Below is the code snippet I used to load the file(Scene.js) ...

Establishing express routing results in API call returning 404 error indicating resource not found

I need some clarification on how to configure my Express routing using app.use and router. My understanding is that I can create a router and then attach it to a route using app.use() to handle all routing related to that route. Can someone assist me in ...

Wait until the user submits the form before activating Angular validations, and do not display any validation messages if the user deletes text from a text box

I am looking to implement angular validations that are only triggered after the user clicks on submit. I want the validations to remain hidden if the user removes text from a textbox after submitting it. Here is what I need: - Validations should not be dis ...