Is there a way to pass an optional parameter to my angularJS modal? Let's take a look at the code:
TRIGGER CONTROLLER:
$modal.open({
templateUrl: 'UploadPartial.html',
controller: 'photos.uploadCtrl',
resolve: {
preselectedAlbum: function preselectedAlbum() {
return angular.copy($scope.selectedAlbum);
}
}
});
MODAL CONTROLLER:
app.controller('photos.uploadCtrl', [
'$scope',
'$modalInstance',
'$injector',
function uploadCtrl($scope, $modalInstance, $injector) {
if ($injector.has('preselectedAlbum')) {
console.log('happy'); // This should work, but $injector does not find it
} else {
console.log('sad'); // Always lands here instead :(
}
}
]);
NOTE: When I make preselectedAlbum
a dependency, it works but throws an error when not explicitly passed. I want it to be optional.