javascript - Passing of function argument through ng-change not working -


i have array of objects each have name , url property. using ng-options display name property of each object in select list.

i using ng-change invoke function url of selected object function argument. when executing not getting errors, when console logging passed argument in function after invocation, returns undefined. passing url argument not working. great if point me right direction.

here comes html:

<div ng-controller="taskchartctrl">   <select ng-model="selectedp" ng-options="project project.name project in projectlist" ng-change="populategraphs(project.url)">     <option value="">select project</option>   </select> </div> 

this controller code:

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;         //rest of function code using $scope.selectedp     } 

sample of projectlist after has returned:

$scope.projectlist = [{     'name':'projectname',     'url':'projecturl' }, {     'name':'projectname2',     'url':'projecturl2' }, {     ... }] 

any appreciated.

try:

ng-change="populategraphs(selectedp.url)" 

the model of select selectedp, want selected value there.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -