The function is not valid due to an angular-parse argument

This is my first experience with using angular and parse.com.
I encountered the following error:

Error: Argument 'eventList' is not a function, got undefined

when attempting to execute the following angular code:

var main_app = angular.module('getParse', []);
main_app.controller('eventList', function() {
var mainTable = document.getElementById("mainTable");
mainTable.hidden = true;
Parse.Cloud.run("MJSEvent_All",{}, {
    success: function(results) {
        //console.log(eventObj);
        var objects = results['objects'];

        for (i = 0; i < objects.length; i++) {
            var tr = document.createElement('TR');
            var td = document.createElement('TD')
            td.appendChild(document.createTextNode(objects[i].get('title')));
            tr.appendChild(td)

            var speakerObj = objects[i].get('session2')[0].get('speaker2')[0];
            var td = document.createElement('TD')
            td.appendChild(document.createTextNode(speakerObj.get('displayName')));
            tr.appendChild(td)

            mainTable.appendChild(tr);
        }
    },
    error: function(errorObj) {
        console.log(errorObj);
    }
});});

Below is my html code snippet:

<div class="row" ng-app="getParse" ng-controller="eventList">
    <h3>Event List</h3>
    <table border=1 id="mainTable">
        <tr>
            <th>Title</th>
            <th>Speaker</th>
        </tr>
    </table>
</div>

If you have any insights on how I can resolve this issue, please share them. Thank you!

Answer №1

Looking for additional code? Check out the code snippet below and how it functions on this JSFiddle link

<div class="row" ng-app="getParse" ng-controller="eventList">
<h3>Event List</h3>
  <table border=1 id="mainTable">
    <tr>
      <th>Title</th>
      <th>Speaker</th>
    </tr>
  </table>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.0/angular.min.js"></script>


<script>var main_app = angular.module('getParse', []);
main_app.controller('eventList', function() {
  var mainTable = document.getElementById("mainTable");
  mainTable.hidden = true;
});</script>

Answer №2

After making adjustments to my code, the error has shifted to a different issue.
Upon further investigation, I discovered that integrating the Parse App key and Parse JS key within the angular module resolved the problem, rather than keeping them in separate JavaScript files or scripts.
I successfully resolved the error and can now retrieve the desired object from the Parse cloud code.

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

Creating a custom ID for a Firebase POST request

Is it possible to assign a custom ID in Firebase when using the POST method? For example: { "users": { "user_one": { "username": "jdoe", "password": "123" } } } I'm currently working on a Vue.js project and I want to save ...

I encountered a crash in my app because of an error in my Node.js backend code that was posting the accessories and slug into the database

My node.js backend code is responsible for adding the accessory and slug to the database, but I am encountering app crashes. const express=require('express'); const Category = require("../models/Category"); const slugify=require('s ...

The function $(...) does not recognize tablesorter

Currently, I am encountering issues with the tablesorter plugin as my system is unable to recognize the existing function. It is unclear whether there might be a conflict with other JavaScript files, especially since I am implementing changes within a Word ...

What is the best way to delete a nested child object using a specific identification number?

Here is the current json structure: $scope.dataList = [{ CompanyName: null, Location: null, Client: [{ ClientId: 0, ClientName: null, Projects:{ Id: 0, Name: null, } }] }]; I'm attempting to remo ...

Is there a way to verify an email address and transfer form data to a different HTML page for printing?

How do I troubleshoot email validity checking issues in my form? It works fine when no characters are entered, but fails when characters are inputted. What could be causing this problem? Additionally, I want to open a new HTML sub-file after form submissi ...

Coloring a table in vue.js based on performance rankings

I'm facing an issue with sorting my data performance in vue js. Here is the script I have created so far: <template> <div> <div class="row"> <h2> Campaign Performance </h2> <table class=&q ...

Encountering an illegal invocation error in jQuery

Recently delving into the world of jQuery, I am attempting to call a C# function from JavaScript using AJAX and jQuery. Additionally, I need to pass some parameters while making the call to the C# function. Here is how I am attempting to achieve this: var ...

Transferring Parameters to EJS Template in Node.js

Hey guys, I'm having an issue with rendering a MongoDB record in my .ejs file. Strangely, when I console.log the variable before the end of my route, I get the expected value. However, it becomes undefined in the .ejs file. Here is the code snippet: ...

What is a way to activate the onSelectionChange event only when the cursor moves without any changes in the input?

In my React Native app, I have a use case where I want to implement mentions. This requires calling a function on the onSelectionChange event only when the text in the input remains unchanged but the caret position has moved. Currently, the onSelectionCha ...

Navigating manually in ui-router with AngularJS 1.7 is ineffective

A state configuration within my application is as follows: function stateConfig($stateProvider) { $stateProvider .state("home", { url: "/", templateUrl: "/app/home/template/home.html", controller: "HomeContr ...

Tallying the number of words delimited by a comma

Here is how my counter function is structured: function count() { var value = ids.val(); return (value == '') ? 0 : value.replace(/\s,?|,$/g, '').split(',').length; } After checking the returned value, data is ...

Angular 2 is not recognizing the element 'router-outlet'

I am currently utilizing universal-cli... This is how my app.node.module.ts appears: /** * This file and `main.browser.ts` are quite similar, for now! * By separating these, you can create logic, imports, etc that are "Platform" specific. * If you wis ...

Developing a dynamic modal using Angular and embedding Google Maps within an iframe

I'm currently working on implementing a modal in my Angular application that, when opened, displays Google Maps within an iframe. The problem I'm facing is that the iframe isn't loading and I'm receiving this error in the browser conso ...

Utilizing angularjs ng-repeat directive to present JSON data in an HTML table

I've been struggling to showcase the JSON data in my HTML table using AngularJS ng-repeat directive. Here's the code snippet: <thead> <tr> <th ng-repeat="(header, value) in gridheader">{{value}}</th> </tr> </ ...

Navigate between pictures using hover in jQuery

I am working on creating a feature where images cycle through individually every 2 seconds, but switch to the right image when its associated link is hovered. So far, I have managed to make the images show up on hover, but I am struggling with getting them ...

The Johnny-Five stepper initiates movement within a for-loop

I am new to using node.js and johnny-five. I want to move a stepper motor 5 times with 1000 steps each. Here is what I have tried: do 1000 Steps in cw ; console.log('ready); do 1000 steps; console.log('ready') ... It woul ...

Private route displaying unexpected behavior when making API call

A snippet of code I have been working on is partially functioning (refer to the last paragraph for a detailed description): App.Js: export default function App() { const [isLoggedIn, setisLoggedIn] = useState(null); const logIn = () => { setisLogg ...

The jQuery dropdown menu smoothly expands to reveal all hidden submenu options

I'm currently encountering an issue with jQuery. I am trying to create a responsive drop-down menu with sub-menus. The behavior I want is that if the window width is less than 700px, the submenus will trigger onClick. And if the window is wider than 7 ...

Interacting with Angular 2 Components Inside <router-outlet>

In the header component, there is a search bar. Below that, within the same component, there is a "router-outlet". After pressing enter in the search bar (input field), the search string (event.target.value) should be sent to the component inside the rou ...

Having trouble with tabs in jQuery?

I'm having trouble setting up tabs in a reservation form with 3 tabs that include text boxes for user input. I can't seem to get it working properly and I'm not sure where I've gone wrong. Could it be due to the placement of the content ...