0

Without going to much into the why, I am working on a littleapp that will do some simple read/write to a server side MS Access (mdb) file (insert booos here), however there are multiple mdb files I can work with. What I want to do is present the user with a drop down of the mdb files that can be opened. The one they select will become the "active" database. It's simple enough provide them with a drop down mdb options, such as <select ng-options="season.name for season in seasonsCtrl.seasons" ng-model="season" ng-change="seasonsCtrl.getComps(season)"></select> this data gets pulled back from my angular SeasonsController via a $http.get. However this is where it gets a little tricky, I want to populate another drop down, with comps based on selected database file. Still somewhat simple, as you can see I use the ng-change, and pass in the season.name var and again via another $http.get method I am able to pull down the comps, this works <select ng-options="(comp.hTeam.abbrev + ' vs ' + comp.vTeam.abbrev + ' at ' + comp.arena) for comp in seasonsCtrl.comps" ng-change="seasonsCtrl.getTeams(comp)" ng-model="comp"></select>, however when I go to populate a 3rd (and final) drop down with the teams in that comp, I want to pass in the comp, but here in lies the problem, I am not passing along the season file anymore, so my ASP.NET MVC controller does not know what season to open up and work with (as with each request the controller is created/destroyed). <select ng-options="team.abbrev for team in seasonsCtrl.teams" ng-model="team"></select>

I've been giving this some thought and have a few rough ideas, but I'm not sure which way to go, or if there is a completely and utterly better approach out there that I am missing?

Idea 1

on my season ng-change method, pull down a more complex json object that has all the data I need. ex json...

  {
      "name": "test",
      "comps": [
        {
          "comp1": {
            "teams": [
              "team1"
              :
              {
                "id": 5,
                "abbrev": "t1"
              },
              "team2":{
                "id": 89,
                "abbrev": "t1000"
              }
            ]
          }
        }
      ]
    }

not sure exactly what the bind syntax would look like

Pro I have all the data I would need con more data than I need

idea 2

On the server side create routing methods similar too...

config.Routes.MapHttpRoute(
                name: "SeasonApi",
                routeTemplate: "api/Season/{season}/{action}",
                defaults: new
                {
                    controller = "Season",
                    id = RouteParameter.Optional
                }
            );

with a calls similar to...

http://localhost:13102/api/Season/Demo99/GetComps and http://localhost:13102/api/Season/Demo99/GetTeamps?comps=t

idea 3

Cache the active database server-side somehow... not exactly stateless, but this a small app with a very small scope, and a very finite number of users (like 2)

One overall question I have is what is the best way to bind data to drop downs that affect the data of other drops downs? doing $http.get on ng-change.. seems wrong to me? I have some difficultly describing the problem in a google search to even find better resources.

Thanks for any help...

6
  • why would doing a request triggered by a change event be wrong ... it is the norm. Question itself is far too long ... try to narrow it down to specifics with a little better formatting Commented Oct 20, 2015 at 20:48
  • ok, maybe not wrong... idk, if its the norm.. that's good. Just seems like there would be a better way to let setup the dependencies and let angular do the heavy lifting? Commented Oct 20, 2015 at 20:49
  • I would think that idea 2 would be the easiest to implement, and make the most sense.... what challenges did you have with implementing it? Commented Oct 20, 2015 at 20:50
  • I guess client side angular wise, where would be the best place to store that databse var? how would I pass it into a ng-change call,like ng-change="seasonsCtrl.getTeams(XXseasonXX, comp)", and how do I update that call to call with the currently selected season, from the season drop down? is it in the $scope var somehwere? Commented Oct 20, 2015 at 20:56
  • How does scoping within `<select>' tags work? Commented Oct 20, 2015 at 21:04

0

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.