I have a set of objects that get resolved using :resolve
I also have a controller that I define by passing it the name as a string but I need to pass in the resolved objects to it.
I know it can be done like this:
resolve: { title: 'My Contacts' },
controller: function($scope, title){
$scope.title = 'My Contacts';
}
}
but I need to do it like this:
resolve: { title: 'My Contacts' },
controller: 'ResultsController'
}
How can I pass in 'title' to my controller in this sense?
Thanks, James
Try this one out (it should work):
// State configuration...
{
resolve: {
title: function () {
return 'My Contacts';
}
},
controller: 'MyCtrl'
}
// Controller
app.controller('MyCtrl', function ($scope, title) {
$scope.title = title;
console.log($scope.title); // -> 'My Contacts'
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments