Take a look at this code snippet:
bank.config(function($stateProvider) {
$stateProvider
.state('main.bank', {
url: '/',
controller: 'BankCtrl',
resolve: {
money: function(bankResource) {
return bankResource.getMoney();
},
templateUrl: 'bank/bank.html'
});
});
In the above code, the bank.html
template is rendered once the resolve function completes.
I am interested in displaying a specific template based on the outcome of my money
function.
For instance:
If money
returns an object with items, I would like to render bank.html
However, if money
returns an empty object, then display empty-bank.html
How can I implement this functionality within my $stateProvider? Alternatively, would it be more appropriate to use a directive for this purpose?