Reputation: 260
Ive read docs about templateUrl and it takes only $stateParams as function param, so then I've checked templateProvider and docs says that it can only return html views ('view.html').
PROBLEM
I'm using mvc 5 and in templateUrl I just reference to my mvc view controller.
But now I want to choose template dynamically based on resolved promise from factory.
The result of it is that desired view is empty. I'm getting empty view and console is clean.
Ive checked the result of console.log($templateRequest('groupView/addNewGroup'));
(screen above)
and I got html, but my view is empty.
Is it possible to reference to mvc controller instead of returning '.html'file in templateProvider?
MY CODE
.state('addNewGroup', {
url: '/group/new',
resolve: {
isUserLoggedIn: function ($templateRequest, checkPermission) {
checkPermission.checkPermission()
.then(function (result) {
if (!result) {
return $templateRequest('groupView/login');
} else {
console.log($templateRequest('groupView/addNewGroup'))
return $templateRequest('groupView/addNewGroup');
}
});
}
},
views: {
"leftPanel": {
templateUrl: '/groupView/simpleLeftPanel',
controller: 'simpleLeftPanelCtrl'
},
"content": {
templateProvider: function (isUserLoggedIn) {
return isUserLoggedIn;
},
}
},
});
Upvotes: 0
Views: 127
Reputation: 260
I just needed to add return before checkPermission, like that:
return checkPermission.checkPermission()
.then(...)..
Now, its all working great.
Upvotes: 0