Issue with passing function argument through ng-change event is not being resolved

I have a collection of objects with both name and url properties. Utilizing ng-options, I am able to present the name property of each object in a select list.

Subsequently, I utilize ng-change to trigger a function with the selected object's url as the argument. Although there are no errors during execution, upon logging the passed argument within the function after calling it, the result is undefined. It seems that something is amiss in passing the url as an argument. Assistance in determining the correct approach would be greatly appreciated.

Below is the provided HTML:

<div ng-controller="TaskChartCtrl">
  <select ng-model="selectedP" ng-options="project as project.name for project in projectList" ng-change="populateGraphs(project.url)">
    <option value="">Select A Project</option>
  </select>
</div>

And here is the code for the controller:

mod.controller("TaskChartCtrl", ["$scope", "$http", function ($scope, $http) {


    $scope.projectList = [];

    $http.get('https://api.freeagent.com/v2/projects',     config).then(function(response) {
        $scope.projectList = response.data.projects;
    });


    $scope.populateGraphs = function(projectUrl) {
        console.log(projectUrl);
        $scope.selectedP = projectUrl;
        //REMAINING FUNCTION CODE UTILIZING $scope.selectedP
    }

An illustration of projectList post retrieval:

$scope.projectList = [{
    'name':'projectName',
    'url':'projectUrl'
}, {
    'name':'projectName2',
    'url':'projectUrl2'
}, {
   ...
}]

Any form of guidance would be highly valued.

Answer №1

Give this a shot:

ng-click="updateGraph(selectedP.link)"

The selection model is named selectedP, so make sure to extract the chosen value from there.

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

Ways to extract the final digit from a format such as an IP address in JavaScript

Is there a way to retrieve the last digits 192.168.1.180 For instance: From the IP address 192.168.1.180, I would like to extract 180. Thank you in advance ...

Tips for incorporating Emoji into a messaging platform similar to SendBird (non-native, web-based application)

Hey everyone! I'm currently working on a project that involves integrating the "SendBird" messaging service. I've successfully implemented all the basic functions, but now I want to incorporate Emoji for better user experience. I'm feeling a ...

Determine if the html element is wrapping to a new line when zoomed in or when the text size on Windows is increased

My webpage has 2 labels displayed side by side, but due to the system text size being set at 150% (which is recommended) in Windows, the second label does not have enough space and gets pushed below the first label. I am looking for a way to determine if t ...

Tips for getting a plugin to function properly when the page is refreshed in Nuxt app

I am currently incorporating the vue GAPI plugin into my project. While it functions smoothly when navigating between pages, I encounter an error upon refreshing: vue-gapi.common.js?15fd:241 Uncaught (in promise) Error: gapi not initialized at GoogleAuth ...

I am facing an issue where the table in my Laravel Vue component is not displaying the data from

Recently, I've been diligently following an instructional series on VUE applications by a highly recommended YouTuber. Every step was meticulously executed until I hit a roadblock out of nowhere. The data from my database refuses to display on the fro ...

Angular date selection with a range of plus two days, factoring in the exclusion of weekends

I am currently using a mat date picker range with specific logic. The minimum date that a user can select on the calendar is set to + 2 days. For example, if today's date is July 20, 2022, the minimum selectable date would be July 22, 2022. However, ...

What's stopping the error exception from showing up on the client side?

Here's the scenario: I have an action method called SavePoint that contains some logic and throws a System.ArgumentException with the message "Error, no point found". Additionally, there is an ajax function named saveFeature which makes a GET request ...

Using JQuery validate to extract the interest rate from a regular expression

I am looking for a regular expression that can extract the interest rate. I need it to accept values such as: Examples: 0 0.4 0.44 4 44 4.00 44.00 4.2 4.22 44.22 Minimum value allowed is 0 and maximum is 99.99 The regular expression should be ab ...

Auto-fill input field with URL parameter values using JavaScript or jQuery

I am in possession of a URL http://www.example.com/state=survey&action=display&survey=39&zone=surveys&currency=Denmark Upon accessing the above link, a user will be directed to a new page containing a form. Within this form, there is an i ...

tips for enabling communication between the server and client

As someone who is new to the world of web development, please bear with me as I ask a question out of curiosity. I am wondering if there is a method for the server to push messages to clients. For instance, imagine a client's webpage featuring a news ...

I have difficulty generating appropriate pseudonyms

Struggling to create aliases in my react project (CRA 3.1.1) has been a challenge for me. Despite attempting various methods, I have not been successful in achieving it. The only success I've had so far is aliasing the simple "src" folder based on som ...

Turn off the ability to debug XHR requests in the developer tools of all web browsers for my website

Is there a method to prevent website users from viewing the communication between my web application and the server via ajax requests? Is there a way to achieve this on my website using code? I want to make sure that the XHR, Ajax calls, and responses ca ...

Positioning elements at the bottom of the container

There is a dilemma that only those in the world of web development will understand. Beware! I have envisioned a layout for a website I am constructing. The concept involves tilted <hr/> elements on the page, with text wrapping around them (refer to ...

What is the process for completing a form with Protractor and TextAngular?

I'm currently attempting to submit a form that utilizes TextAngular for certain input fields. Despite my efforts, I haven't been successful in finding information on how to fill out these fields. The closest solution I found was this, but when I ...

JavaScript and Angular are used to define class level variables

Hello, I'm currently diving into Angular and have encountered an issue with a class level variable called moratoriumID in my component. I have a method that makes a POST request and assigns the returned number to moratoriumID. Everything seems to work ...

Discovering the way to retrieve background height following a window resize using jQuery

Is there a way to obtain the background height once the window has been resized? div { background-image: url(/images/somebackground.jpg); background-size: 100% 90%; background-repeat: no-repeat; width: 70%; background-size: contain; ...

Retrieve information according to the currency specified

In my database, I have a table of tickets with prices listed in USD. If someone from a country outside the US wants to purchase a ticket, I'd like to display the prices in their local currency for better user experience. However, converting these pric ...

Discovering elements with Selenium

While using selenium, I stumbled upon this web element: <td style="padding-right: 10px; " **onclick="javascript:show_me('CarDetails.php?CarID=2358912&SubCatID=1**', '2358912', 560, 'ActiveLinkVisited');stat( '../& ...

Troubleshooting problem with Angular's ng-repeat directive in dealing with varying number of child objects

I am currently dealing with tree-structured data where the parent nodes can have an indefinite number of children, and those children can also have an indefinite number of children, creating a deeply nested structure. While I have successfully formatted th ...

Creating a file logging system with log4js to capture Console logs

Is there a way to automatically log all console logs, including failed expectations and exceptions, to a file without using try and catch in JavaScript? In Java's LOG4j, the rootlogger feature does this by default. Is there a similar functionality ava ...