angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
.directive('listItem', function() {
return {
restrict: 'E',
require: '^list',
replace: true,
transclude: true,
scope: {
onSelect: '&',
onDelete: '&',
onButtonClicked: '&',
canDelete: '@',
canReorder: '@',
canSwipe: '@',
buttons: '=',
},
template: '
\
\
\
\
\
\
\
\
\
\
\
\
',
link: function($scope, $element, $attr, list) {
$scope.isEditing = false;
$scope.deleteIcon = list.scope.deleteIcon;
$scope.reorderIcon = list.scope.reorderIcon;
list.scope.$watch('isEditing', function(v) {
$scope.isEditing = v;
});
}
}
})
.directive('list', function() {
return {
restrict: 'E',
replace: true,
transclude: true,
scope: {
isEditing: '=',
deleteIcon: '@',
reorderIcon: '@'
},
// So we can require being under this
controller: function($scope) {
var _this = this;
this.scope = $scope;
$scope.$watch('isEditing', function(v) {
_this.isEditing = true;
});
},
template: '',
compile: function(element, attr, transclude) {
return function($scope, $element, $attr) {
var lv = new ionic.views.List({el: $element[0]});
if(attr.animation) {
$element.addClass(attr.animation);
}
}
}
}
})