1

I have an interesting scenario happening right now and it's confusing me, this question is initially meant for those who are familiar with Angular UI Grid. However, you are welcome to answer.

I have a UI Grid that I call a drop down through a separate html page in the grid itself because the dropdown values dynamically change. Now I have ng-model of this drop as ng-model="row.entity.someValue" this would be the value of the $scope.someDate.someValue that is obtained from the grid with field: 'someValue'. The issue I'm having at hand is after selection I cannot fire a function call, I'm avoiding id="" calls because I want the code to be consistent and not use getElementById calls. I've tried ng-selected, ng-change even ng-class (knowing it wouldn't work) What I'm trying to do is fire a function with the selected value as a parameter and I cannot get the function to fire. What am I missing here?

Here is a same code of what I'm trying to achieve:

 <div>
    <select ng-model="row.entity.someValue" class="dropdownWidth" ng-selected="someFunction(selectedValue)" >
        <option ng-repeat="selectedValue in grid.appScope.someArray" value={{selectedValue}}>{{selectedValue}}</option>
    </select>
</div>

UPDATE Answer below

McMintz
  • 254
  • 6
  • 19
  • 1
    Possible duplicate of [Angular JS Action on ng-change the select dropdown](http://stackoverflow.com/questions/29396801/angular-js-action-on-ng-change-the-select-dropdown) – Heretic Monkey Jan 25 '17 at 20:48
  • Sadly, that still doesn't help my case. I even just resorted to attempting the use of document.getElementById but that has failed as well... I'm curious if the ui grid is preventing function calls from firing after a selection has been chosen. – McMintz Jan 25 '17 at 21:15
  • If ng-change isn't working might be that your issue is elsewhere. Share more code or better yet a plunk. – jbrown Jan 25 '17 at 21:25
  • I actually figured out my problem, I had forgotten to call the function as grid.appScope.someFunction(row.entity.someValue) since I was pertaining the grid cell's value as an external scope variable – McMintz Jan 26 '17 at 20:31

1 Answers1

1

The answer was right there in front of me, which I keep forgetting. Every time a call to a grid cell is made outside of the controller you always apply grid.appScope in anything thing pertaining to the cell's value

in my case I was just calling ng-selected="someFunction(selectedValue)" when in fact I should've been calling ng-selected="grid.appScope.someFunction(row.entity.someValue)". Now it works perfectly, hopefully this scenario will be of some good use for anyone in the future!

McMintz
  • 254
  • 6
  • 19