I posted the below on SO; anyone here have thoughts/workarounds for this, since Ionic is integrated with ui-router ?
I’m using Ionic Framework, which is integrated with ui-router, and I’ve found that models that are associated with promises via my controller aren’t updated in the UI when, eg, a REST call via $http returns. Is this happening because I’m not using “resolve” in the state setup ? Is it required to use “resolve” for this to work ?
If “resolve” is required for this to work, then I find it horrible that my app-related code is spread among “resolve” and my controller; why would that be necessary ? What about cases where it’s not desirable to have the framework wait for “resolve” to finish ( ie, make a bunch of network calls ) before my controller executes ?
Below, summary and test are set via MyCtrl. I’m seeing “my test” display properly, but not “summary.name”. I’m seeing that MySvc.get()'s callback executes as expected, but summary.name’s updated value doesn’t appear on the UI.
Any suggestions on why summary.name’s updated value isn’t appearing on the UI ?
You don’t need to use resolve. $http takes care of that for you. However, you’re not using the promise that is returned by $http.get. You can’t just assign it to $scope.summary. By doing that, you are assigning the promise to that scope property.