1

This script

https://gist.github.com/whisher/6231714

give me this error

Error: Unknown provider: albumsProvider <- albums

this.app.config(($routeProvider:ng.RouteProvider) => { 
            $routeProvider.
                    when('/', {
                        templateUrl: './view.html', 
                        resolve: {
                            albums: function(Album) {
                               console.log(Album);
                                return Album.getResource().query();
                            }
                        },
                        controller: 'AlbumController',
                        })

           } ); 
class AlbumController {
    constructor (private $scope,private albums) {
        this.$scope.test = '20 whatsomething';
        this.$scope.albums = albums;
    }
}

the Album is in the scope console.log(Album); so

I'm waiting to get albums

in my controller but I get

only the above error :(

I don't really know which way to turn

can you give me an hint ?

Thanks

4
  • Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. Commented Aug 14, 2013 at 15:02
  • ok, I've edited the question ^^ Commented Aug 14, 2013 at 15:41
  • The error is saying that angular can't resolve your dependency albums. Do you have a service 'albums'? Can you also post that code? Commented Aug 14, 2013 at 18:27
  • @John Hi, the service is Album, the albums is the resolve scope for the view.Bye Commented Aug 15, 2013 at 8:45

1 Answer 1

0

Updated Answer Angular can only dependency inject things you register with it. Since you have

this.app.service ('Album',Album);

You can only request for Album and not album. So modify your constructor from:

constructor (private $scope,private albums) {
    this.$scope.test = '20 whatsomething';
    this.$scope.albums = albums;
}

to:

    // You can only get variables injected that you registered with angular: 
    constructor (private $scope,private Album) {
        this.$scope.test = '20 whatsomething';

        this.$scope.albums = Album.getResource(). /* Send your request based on http://docs.angularjs.org/api/ngResource.$resource */
    }

Playground

4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.