2

私は次のことをしようとしています:

var myApp = angular.module('myApp', []);
myApp.provider('routeResolver', ['$q','$rootScope',function($q, $rootScope)
    {        
        console.log( $q, $rootScope );
        this.$get = function()
        {
            return this;
        }
    }]

);

ただし、これによりエラーが発生します。Unknown Provider $q

そこで、コードを次のように変更しました。

myApp.provider('routeResolver', ['$qProvider','$rootScopeProvider',function($q, $rootScope)
    {        
        console.log( $q.defer() );
        console.log( $rootScope );
        this.$get = function()
        {
            return this;
        }
    }]
);

ただし、これにより のエラーが発生しますuknown function.。やっても:

console.log( $q.$get().defer() );

動作しません。何か案は?

4

1 に答える 1