I'm working on my first Angular project and currently stuck (again).
My problem is I have two functions that needs to implement in the Angular config.
What I cannot understand is, both of there modules using <angular module>.config
, I don't know how to combine these two , because when I read the Angular docs it seems like it gets a name, and a function.
Following is my current code (and these two works individually)
var myApp = angular.module('myApp', ['ui.router'])
.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise("/state1");
$stateProvider
.state('state1',{
url: 'state1',
templateUrl: "../pages/form.html"
});
$locationProvider.html5Mode(false);
});
myApp = angular.module('myApp', ['facebook'])
.config([
'FacebookProvider',
function(FacebookProvider) {
var myAppId = '<FB app id>';
FacebookProvider.init(myAppId);}
]
)
How can I combine these two functions in to one
var myApp = angular.module('myApp', ['facebook','ui.router']).config(
facebook functon and ui-route function
)
I have found almost the same SO question here but unfortunately no answer.
var myApp = angular.module('myApp', ['ui.router','facebook'])
.config(function($stateProvider, $urlRouterProvider, FacebookProvider){
$urlRouterProvider.otherwise("/state1");
$stateProvider
.state('state1',{
url: 'state1',
templateUrl: "../pages/form.html"
});
$locationProvider.html5Mode(false);
var myAppId = '<FB app id>';
FacebookProvider.init(myAppId);
});
Is that what you want?
Alternatively, you can chain configs to keep things isolated like so
var myApp = angular.module('myApp', ['ui.router','facebook'])
.config(function($stateProvider, $urlRouterProvider){
... state provider config ...
})
.config(function(FacebookProvider){
... facebook provider config ...
});
or you could split them right up like so
var myApp = angular.module('myApp', ['ui.router','facebook']);
myApp.config(function($stateProvider, $urlRouterProvider){
...
});
myApp.config(function(FacebookProvider){
...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With