How to pass a value to a Modal form and manage the output of form select options on said form, angularJS Style!

I have a simple single page application with some data output on it.  If a user clicks on the USERNAME, the changeABuyer function initiates a modal form which transitions in.  The modal form contains a form select with all available USERNAMES.

What I would like to learn is two fold:
A: Pass the USERNAME that the user clicks to the 'changeAUserModal' modal form, and OMIT USERNAME from Select Options of the changeAUserModal Modal Form
B: Pass the USERNAME that the user clicks to the 'changeAUserModal' modal form, , and tag USERNAME as 'SELECTED' in the Select Options of the changeAUserModal Modal Form



USERNAME Data Output within SPA Index:
ow="fsID" ng-repeat="f in currentRulesF" ng-model="fedTable" ng-if="f.USERNAME != 'FAILURE'">
    <td ng-click="changeABuyer($index)" class="pointer">{{f.USERNAME}}</td>
    <td ng-click="changeARange($index)" class="pointer">{{f.LOW_DOLLAR}} - {{f.HIGH_DOLLAR}}</td>
    <td>
        <button class="btn btn-primary" id="removeRule" type="button" ng-click="removeRule($index)">
            <span class="glyphicon glyphicon-minus" aria-hidden="true"></span> Rule
        </button>
    </td>
</tr>

Open in new window


changeABuyer Function within controller.js
ope.changeABuyer = function(index) {
    $scope.changeIndex = index;
    $scope.BuyerDD = "";
    $('#changeAUserModal').modal('show');
}

Open in new window


changeAUserModal Modal Form within SPA Index:
<div class="modal fade" role="dialog" id="changeAUserModal">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal" aira-hidden="true">×</button>
                <h3>Change A Buyer</h3>
            </div>
            <div class="modal-body">
                <select ng-model="BuyerChangeDD" id="BuyerChangeDD" ng-options="aBuyer.NAME for aBuyer in buyerList"></select>
            </div>
            <div class="modal-footer">
                <a class="btn btn-primary" ng-click="BuyerChanged(BuyerChangeDD)" type="submit">Change</a>
                <a href="#" class="btn" data-dismiss="modal">Cancel</a>
            </div>
        </div>
    </div>
    <button ng-show="changesMade" type="button" class="btn btn-default" ng-click="saveRules()">Save Changes</button>
</div>

Open in new window

LVL 1
brianmfallsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brianmfallsAuthor Commented:
I managed to answer half of my question...  The changes I made pass in the USERNAME, and make sure that the USERNAME is selected in the drop down list.

Change to Data Output (Link) - Passing ",f.USERNAME" as an attribute of the changeABuyer function:
<td ng-click="changeABuyer($index,f.USERNAME)" class="pointer">{{f.USERNAME}}</td>

Open in new window

Addition & Change to changeABuyer function - Added 'userName' as a function attribute and added line beginning with "$scope.BuyerChangeDD":
$scope.changeABuyer = function(index,userName) { //change
    $scope.changeIndex = index;
    $scope.BuyerDD = "";
    $scope.BuyerChangeDD = { NAME: userName };  //addition
    $('#changeAUserModal').modal('show');
}

Open in new window

Change to Form Select Element - Appended " track by aBuyer.NAME" to the ng-options attribute:
<select ng-model="BuyerChangeDD" id="BuyerChangeDD" ng-options="aBuyer.NAME for aBuyer in buyerList track by aBuyer.NAME"></select>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brianmfallsAuthor Commented:
I suppose half of a solution is better than no solution.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.