0

I have a simple NG-Admin project. I need to make a couple API calls that are not the default functionality of their awesome product. I see they use Restangular and I'd like to continue using it too. What is the normal way to reference a library that is included in another third party's library? I tried:

var adminApp = angular
    .module('app', ['ng-admin', 'Restangular'])
    .run(run);

But it tells me that I do not have the library. This means that I would need to include both Restangular and Angular on my index page, where ng-admin also includes them. Am I able to inject or pull a reference from their library to use it? Or is it fine to also include the libraries? Will I need to worry about keeping the version the same?

I have seen where you can reference the providers in their book to change headers and such, but not to use the methods provided such as Restangular.all('accounts').

I'm happy to rtfm, just not sure where to start for this problem.

I'm still pretty new to Angular, forgive me if this is an overly simplistic question.

1 Answer 1

1

The ng-admin module uses and depends on the restangular module, just like you wrote.

If you add ng-admin as a dependency, you will get access to ng-admin as well as to all its dependencies.

All you should have to do is:

var adminApp = angular.module('app', ['ng-admin']);

Note that the module is called restangular, while the service is called Restangular.

From the restangular starter guide:

// Add Restangular as a dependency to your app
angular.module('your-app', ['restangular']);

// Inject Restangular into your controller
angular.module('your-app').controller('MainCtrl', function($scope, Restangular) {
  // ...
});

So in your case you only need to add ng-admin as a module dependency, then inject the Restangular service in for example your controller to use it.

Sign up to request clarification or add additional context in comments.

1 Comment

Great, thanks for the detailed explanation! If I could pretend the front end didn't exist I'd be in one happy bubble.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.