Question

I'm trying to implement a Facebook provider (angular-facebook.js) as show in the below plnkr:

http://plnkr.co/edit/dDAmvdCibv46ULfgKCd3?p=preview

However, I've made a bit of a hash with my config files. The plnkr example doesn't use a route provider so I'm unsure how to structure my .config to both utilize the route provider and initialize my Facebook implementation:

Current but Not Working

'use strict';
var myApp = angular.module('myApp ', ['facebook'])
.config(
    ['FacebookProvider',
    function(FacebookProvider){
        var myAppId = '4605923966';

        FacebookProvider.init(myAppId);
    },
    function($routeProvider)
    {
        $routeProvider.when('/admin/area',
        {
            templateUrl: 'app/admin/area/index.html'
        });

    }]
);
Was it helpful?

Solution

The method config only takes one function as a parameter, so you need to inject both FacebookProvider and $routeProvider into it like this:

'use strict';

var myApp = angular.module('myApp ', ['facebook'])
.config(['FacebookProvider', '$routeProvider',
    function(FacebookProvider, $routeProvider) {
        var myAppId = '4605923966';

        FacebookProvider.init(myAppId);

        $routeProvider.when('/admin/area', {
            templateUrl: 'app/admin/area/index.html'
        });
    }]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top