cobuild-angular-stack
Version:
Base stack angular sass jade gulp
54 lines (48 loc) • 1.48 kB
JavaScript
(function (module) {
'use strict';
module.controller('AdminExperienceListController', AdminExperienceListController);
AdminExperienceListController.$inject = ['$scope', '$translate', '$uibModal', 'Experiences'];
function AdminExperienceListController($scope, translate, $uibModal, Experiences) {
$scope.view = {
experiences: [],
loader: false
}
$scope.getExperiences = function() {
Experiences.find().$promise.then(function(experiences) {
console.log(experiences);
$scope.view.experiences = experiences;
})
}
$scope.createOpen = function() {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'partials/admin.experiences.add.html',
controller: 'AdminExperiencesAddController'
});
modalInstance.result.then(function(experience) {
$scope.view.experiences.push(experience);
}, $scope.error).catch($scope.error);
}
$scope.edit = function(experience) {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'partials/admin.experiences.add.html',
controller: 'AdminExperiencesEditController',
resolve: {
experience: experience
}
});
modalInstance.result.then(function(experience) {
$scope.getExperiences();
}, $scope.error).catch($scope.error);
}
$scope.error = function(err) {
if(err == 'cancel') return false;
toastr.error(err);
}
/*
START MODULE
*/
$scope.getExperiences();
}
})(angular.module('uniko.admin.experiences'));