angularjs - Trigger of function not happening when combo box selected -
i have created tree using bento component. trying have combo box wherein select value , tree nodes matching value selected. function associated combo box change event not getting triggered.
angular js code
var app = angular.module('bentouiapp', ['bento.modern', 'wj', 'bento.d3', 'aa.formextensions', 'aa.notify']); angular.module('bentouiapp').controller('dbconnectionctrl', [ '$scope', '$timeout', function ($scope, $timeout) { 'use strict'; $scope.dbconnections = []; $scope.filteritems = [ {id: '1', title: 'devwatch_w_b'}, {id: '2', title: 'none'} ]; $scope.selectoption = function(selectedval,item) { dbitems = []; alert("function selected"); $scope.dbconnections = []; if(selectedval == 1){ $scope.tree.foreach(function(parent) { //dbitems = parent.items; var i; for(i = 0; < parent.items.length; i++) { if(item.name == parent.items[i].name){ var idx = $scope.dbconnections.indexof(parent.items[i]); if(idx==-1){ parent.items[i].selected=true; $scope.dbconnections.push(parent.items[i]); //parent.items[i].selected=false; } } } }); } } // initialize callback status model $scope.treecallbackstatus = 'n/a'; /*** callback functions ***/ $scope.selecteditemchanged = function (item) { /* cancel user selection */ //return false; var idx = $scope.dbconnections.indexof(item); $scope.treecallbackstatus = 'selected item changed: "' + item.name + '"'; if(idx==-1 && !item.isselected){ $scope.dbconnections.push(item); console.log($scope.dbconnections); } else{ $scope.itemcollapsed(item); } }; $scope.itemexpanded = function (item) { $scope.treecallbackstatus = 'item expanded: "' + item.name + '"'; }; $scope.itemcollapsed = function (item) { $scope.treecallbackstatus = 'item collapsed: "' + item.name + '"'; var idx = $scope.dbconnections.indexof(item); $scope.dbconnections.splice(idx, 1); }; $scope.checkboxclicked = function (item) { if (item.checked) { $scope.treecallbackstatus = 'item checked: "' + item.name + '"'; } else { $scope.treecallbackstatus = 'item unchecked: "' + item.name + '"'; } }; // initialize fef tree data function init() { $scope.tree = []; var parentitem={ collapsed:true, expandonly:true, hidecheckbox:true, iconname:"", id:0, items:[], name:"cs ci" } $scope.tree.push(parentitem); // children of var itema1 = { id : 11, name : "devwatch_w_b", hidecheckbox :true, parent : parentitem }; var itema2 = { id : 12, name : "qawatch_w_b", hidecheckbox :true, parent : parentitem }; var itema3 = { id : 13, name : "devwatch_w_b", hidecheckbox :true, parent : parentitem }; parentitem.items.push(itema1); parentitem.items.push(itema2); parentitem.items.push(itema3); } // ... (edited brevity) ... // simulate server loading 1 sencond delay $timeout(function () { init() }, 1000); } ]);
i have attached jsfiddle code js fiddle
what missing? adding selected item, later can refer requirement.
how make ng-change event working, though function associates in controller?
Comments
Post a Comment