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...