I have a function checkLogin()
which sets a variable in a service. This is always run in app.run(...)
. In one function called by ng-init I want to use this variable to make a call to my backend. The problem is that ng-init is called before, so the call to my backend sends an undefined
variable. What should I do to make sure that checkLogin()
is always called first?
Like this Here login required is a function of service
.state('app.dashboard', {
url: "/dashboard",
templateUrl: "partials/dashboard.html",
controller: 'DashboardCtrl',
activePage:'dashboard',
resolve: {
loginRequired: loginRequired
}