I've seen other questions that ask this, and I don't feel my issue is a duplicate of those.
Breezejs [Q] Unhandled rejection reasons (should be empty)
Unhandled rejection reasons (should be empty)
Okay so I've been following up on breezejs; following the documentation as close as possible as well as the samples, but I keep running into the same problem. The code I will present works in IE9+, and Chrome, but when I try it in IE7 and IE8, it blows up.
here is my server side controller (using webapi 2):
namespace Map.API.Controllers
{
[BreezeController]
public class LocationController : ApiController
{
readonly EFContextProvider<LocationEntities> _contextProvider =
new EFContextProvider<LocationEntities>();
[HttpGet]
public string Metadata()
{
return _contextProvider.Metadata();
}
[HttpGet]
public IQueryable<dbSTATES> States()
{
return _contextProvider.Context.MD_STATE_CD;
}
}
}
here is my angular factory:
mapapp.app.factory('StateContext', ['$http', 'StateModel', function ($http, StateModel) {
configureBreeze();
var dataService = new breeze.DataService({
serviceName: "/Map.API/api/Location"
});
var datacontext = {
getAllStates: getAllStates,
getCachedStates: getCachedStates
};
return datacontext;
/* BLOWS UP AFTER RUNNING MANAGER.EXECUTEQUERY(QUERY) */
function getAllStates() {
var query = breeze.EntityQuery
.from("States");
return manager.executeQuery(query);
}
function getCachedStates() {
var query = breeze.EntityQuery
.from("States").toType('MD_STATE_CD');
return manager.executeQueryLocally(query);
}
function configureBreeze() {
// configure to use webapi
breeze.config.initializeAdapterInstances({ dataService: "webApi" });
}
}
Here is how I'm calling it from my angular controller:
StateContext.getAllStates().then(
function (data) {
var localData = data.results; //never gets here
logger.info("Fetched States");
}).fail(function (e) {
logger.info(e); //always gets here
}).done();
Again, this works fine in modern browsers, but blows up in IE7 and IE8. After doing tons of research, no sources ever came up mentioning that this will fail. Even though BreezeJS documentation made mention of some things failing in IE7, there should be explicit info saying that this will never work.
If I happen to turn off metadata:
var dataService = new breeze.DataService({
serviceName: "/Map.API/api/Location",
hasServerMetadata: false
});
then this works in all browsers. But I would like to have the metadata turned on so that I can do caching. However, my big concern is that even if I get this fixed, I have NO idea if caching will still work in IE7.
Even though I love BreezeJS and it works phenominally with google chrome, I spent hours, days, weeks, and headaches making what I want work in IE7. Adding crazy amounts of browser supporting scripts, ie-shivs and ie-shims.. coming so close, then finding out localStorage isn't supported. I wish BreezeJS would document more about what isn't supported in IE7, I have a large portion of my customers that uses IE7 and IE8, and it's very tough to program things and finding out after hours that it just doesn't work.