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

4
  • 1
    Possible duplicate of Angular JS Action on ng-change the select dropdown Commented Jan 25, 2017 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. Commented Jan 25, 2017 at 21:15
  • If ng-change isn't working might be that your issue is elsewhere. Share more code or better yet a plunk. Commented Jan 25, 2017 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 Commented Jan 26, 2017 at 20:31

1 Answer 1

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.