Answer the question
In order to leave comments, you need to log in
How to improve controllers?
There are two controllers
app.controller 'showDialogCtrl', ['$scope', '$mdDialog', '$mdSidenav', '$mdUtil', ($scope, $mdDialog, $mdSidenav, $mdUtil) ->
$scope.showChange = (event, block, img, name) ->
$mdDialog.show
locals:
parent:
img: img
name: name
block: block
controller: "CategoriesCtrl",
templateUrl:'change.html',
targetEvent: event,
clickOutsideToClose:true
$scope.showAdd = (event, block) ->
$mdDialog.show
locals:
parent:
block: block
controller: "CategoriesCtrl",
templateUrl:'add.html',
targetEvent: event,
clickOutsideToClose:true
$scope.showAddToSource = (event) ->
$mdDialog.show
controller: "addToSouceCtrl",
templateUrl:'add-to-source.html',
targetEvent: event,
clickOutsideToClose:true
$scope.showAddToCategory = (from, to, event) ->
controller: "addToCategoryCtrl",
templateUrl:'add-to-category.html',
targetEvent: event,
clickOutsideToClose:true
$scope.showSettings = (id) ->
return $mdUtil.debounce( ()->
$mdSidenav(id).open()
,100 )()
]
app.controller 'CategoriesCtrl', ['$scope', '$mdDialog', 'parent', "$http", 'localData', ($scope, $mdDialog, parent, $http, localData) ->
$scope.default = 'tag.svg'
$scope.category = parent
$scope.category.newName = parent.name
$scope.change = ->
do $mdDialog.hide;
$http.post "/changeCategory",
icon : $scope.category.img
newName : $scope.category.newName
block: $scope.category.block
name: $scope.category.name
.success ->
do location.reload
$scope.loadIcon = ->
$scope.Icons = localData.Icons
$scope.changeCheck = true
$scope.openMenu = ($mdOpenMenu, event) ->
originatorEv = event;
$mdOpenMenu event;
$scope.changeIcon = (icon) ->
$scope.default = $scope.category.img = icon
$scope.changeCheck = false
$scope.add = () ->
do $mdDialog.hide;
$http.post "/add",
icon : $scope.default
name : $scope.category.name
block: $scope.category.block
.success ->
do location.reload
$scope.delete = (check) ->
if check
$http.post "/delete",
oldName: $scope.category.oldName
block: $scope.category.block
.success ->
do location.reload
]
Answer the question
In order to leave comments, you need to log in
Maybe something extra that should not be in the controller
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question