Last active
February 8, 2017 13:04
-
-
Save gregszero/9a2e54997b47c4207c899ea61e5af24b to your computer and use it in GitHub Desktop.
Remove JHipster modal on edit/new action.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.state('example-detail', { | |
parent: 'entity', | |
url: '/example/{id}', | |
data: { | |
authorities: ['ROLE_USER'], | |
pageTitle: 'Example.example.detail.title' | |
}, | |
views: { | |
'content@': { | |
templateUrl: 'app/entities/example/example-detail.html', | |
controller: 'ExampleDetailController', | |
controllerAs: 'vm' | |
} | |
}, | |
resolve: { | |
translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) { | |
$translatePartialLoader.addPart('person'); | |
return $translate.refresh(); | |
}], | |
entity: ['$stateParams', 'Example', function($stateParams, Example) { | |
return Example.get({id : $stateParams.id}).$promise; | |
}], | |
previousState: ["$state", function ($state) { | |
var currentStateData = { | |
name: $state.current.name || 'person', | |
params: $state.params, | |
url: $state.href($state.current.name, $state.params) | |
}; | |
return currentStateData; | |
}] | |
} | |
}) | |
.state('example.new', { | |
parent: 'example', | |
url: '/new', | |
data: { | |
authorities: ['ROLE_USER'] | |
}, | |
// First You should make it just like the "-detail" state right above. Make a block like | |
views: { | |
'content@': { | |
templateUrl: 'app/entities/example/example-dialog.html', | |
controller: 'ExampleDialogController', | |
controllerAs: 'vm' | |
} | |
}, | |
//Then move resolve out of the $uibModal.open | |
resolve: { | |
entity: function () { | |
return { | |
exampleText: null, | |
id: null | |
}; | |
} | |
}, | |
previousState: ["$state", function ($state) { | |
var currentStateData = { | |
name: $state.current.name || 'example', | |
params: $state.params, | |
url: $state.href($state.current.name, $state.params) | |
}; | |
return currentStateData; | |
}] | |
}) | |
// On edit modal, you need to do a little trick | |
.state('example.edit', { | |
parent: 'example', | |
url: '/{id}/edit', | |
data: { | |
authorities: ['ROLE_USER'] | |
}, | |
// First You should make it just like the "-detail" state right above. Make a block like | |
views: { | |
'content@': { | |
templateUrl: 'app/entities/example/example-dialog.html', | |
controller: 'ExampleDialogController', | |
controllerAs: 'vm' | |
} | |
}, | |
// Trick here! (Only if you are not using @ngInject) | |
// After move resolve out of the $uibModal.open | |
// Add '$stateParams' to your entity | |
resolve: { | |
entity: ['Example','$stateParams', function(Example, $stateParams) { | |
return Example.get({id : $stateParams.id}).$promise; | |
}] | |
}, | |
previousState: ["$state", function ($state) { | |
var currentStateData = { | |
name: $state.current.name || 'person', | |
params: $state.params, | |
url: $state.href($state.current.name, $state.params) | |
}; | |
return currentStateData; | |
}] | |
}) | |
// Then there is a bit of change in your controller. Make clear function look like that: | |
function clear () { | |
$state.go('^'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment