angularjsrestangularsteroids

Issues with Restangular and Appgyver Supersonic


So I have restangular setup on another controller that works fine, however on that controller I don't need to declare supersonic

Working Controller

angular
  .module('working')
  .controller("IndexController", function ($scope, Restangular) {

Working Model

angular.module('working', ['restangular'])
    .config(function(RestangularProvider) {

But having issues with this one, and the only difference seems to be having supersonic in there. Can't take that out as using it to grab the view parameters (supersonic.ui.views.current.params.onValue( function (values) {...)

NotWorking Controller

angular
  .module('notworking')
  .controller('IndexController', function($scope, supersonic, Restangular) {

NotWorking Model

angular.module('notworking', ['restangular'])
    .config(function(RestangularProvider) {

... this gives me IndexController' is not a function, got undefined which I think I figured out is because in the model it is trying to recreate the module instead of reference the existing one (as here - Restangular: Error: Unknown provider: RestangularProvider <- Restangular).

Anyways, if I remove the ['restangular'] then it gives me Unknown provider: RestangularProvider which one would expect.

But then when I add it to the controllers initial module creation:

angular
  .module('notworking', ['restangular'])
  .controller('IndexController', function($scope, supersonic, Restangular) {

... it then gives me Unknown provider: supersonicProvider <- supersonic

No doubt this is due to me being a newb with both supersonic, angular, and restangular, but really struggling, anyone?


Solution

  • Not sure why the Angular code itself might not be working, but if you're not using e.g. supersonic.bind or other Angular-specific APIs, you can just use Supersonic without including it as an Angular service. Just make sure the Supersonic script tag is loaded before Angular.