mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
List demo with animations!
This commit is contained in:
18
js/ext/angular/src/directive/ionicList.js
vendored
18
js/ext/angular/src/directive/ionicList.js
vendored
@ -1,21 +1,24 @@
|
||||
angular.module('ionic.ui.list', ['ionic.service'])
|
||||
angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
|
||||
|
||||
.directive('listItem', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
transclude: true,
|
||||
template: '<li class="list-item">' +
|
||||
template: '<li class="list-item">' +
|
||||
' <div class="list-item-edit" ng-if="item.canDelete">' +
|
||||
' <button class="button button-icon"><i class="icon-minus-sign"></i></button>' +
|
||||
' </div>' +
|
||||
' <div class="list-item-content" ng-transclude>' +
|
||||
' </div>' +
|
||||
' <div class="list-item-buttons" ng-if="item.canSwipe">' +
|
||||
' <button class="button" ng-class="button.type" ng-repeat="button in item.buttons">{{button.text}}</button>' +
|
||||
' <button ng-click="buttonClicked(button)" class="button" ng-class="button.type" ng-repeat="button in item.buttons">{{button.text}}</button>' +
|
||||
' </div>' +
|
||||
'</li>',
|
||||
link: function($scope, $element, $attr) {
|
||||
$scope.buttonClicked = function(button) {
|
||||
button.buttonClicked && button.buttonClicked($scope.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -27,10 +30,11 @@ angular.module('ionic.ui.list', ['ionic.service'])
|
||||
transclude: true,
|
||||
scope: {
|
||||
isEditing: '=',
|
||||
items: '='
|
||||
items: '=',
|
||||
animation: '='
|
||||
},
|
||||
template: '<ul class="list" ng-class="{\'list-editing\': isEditing}">' +
|
||||
'<list-item ng-repeat="item in items" canDelete="item.canDelete" canSwipe="item.canSwipe">' +
|
||||
'<list-item ng-repeat="item in items | filter:{hide:\'false\'}" canDelete="item.canDelete" canSwipe="item.canSwipe" animation="my-repeat-animation">' +
|
||||
' {{item.text}}' +
|
||||
' <i class="{{item.icon}}" ng-if="item.icon"></i>' +
|
||||
'</list-item>' +
|
||||
@ -39,6 +43,10 @@ angular.module('ionic.ui.list', ['ionic.service'])
|
||||
return function($scope, $element, $attr) {
|
||||
var lv = new ionic.views.List({el: $element[0]});
|
||||
|
||||
if(attr.animation) {
|
||||
$element.addClass(attr.animation);
|
||||
}
|
||||
|
||||
$element.append(transclude($scope));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user