要实现的功能,如图:
html代码:
编辑按钮代码:
列表代码:
{ {privateNote.title}} { {privateNote.datetime}}
全选,删除 代码
{ {allSelectOrNot}} 删除
js代码:
.controller('CourseNoteCtrl', ['$scope', '$state', '$location', 'Course', '$stateParams', 'Utilities', 'constant', 'AppAgent', '$window', 'socialSharing', function($scope, $state, $location, Course, $stateParams, Utilities, constant, AppAgent, $window, socialSharing) { $scope.courseNoteTitle = socialSharing.getTitle(); // var detailId = $stateParams.courseId; // Course.getCourseInfo(detailId).then(function(data) { // $scope.courseInfo = data; // alert(courseInfo.name); // }); $scope.privateNoteList = [{ title: "我的笔记1111111", datetime: "YYYY/MMM/DD hh:mm" }, { title: "我的笔记2", datetime: "YYYY/MMM/DD hh:mm" }, { title: "我的笔记3", datetime: "YYYY/MMM/DD hh:mm" }, { title: "我的笔记4", datetime: "YYYY/MMM/DD hh:mm" }, { title: "我的笔记5", datetime: "YYYY/MMM/DD hh:mm" }]; $scope.triggerSubTabs = function(tabName) { var i = $scope.noteTabs.length; while (i--) $scope.noteTabs[i].active = $scope.noteTabs[i]['name'] == tabName ? true : false; angular.element($window).bind('orientationchange', function() { $scope.$apply(); }); }; // $scope.private_note = function() { // $state.go('course.ClassNote.PrivateNote'); // }; // $scope.public_note = function() { // $state.go('course.ClassNote.PublicNote'); // }; $scope.flag = {showDelete:false}; $scope.privateNoteEditAndCancel = "编辑"; $scope.privateNoteEditState = false; //编辑按钮 $scope.privateNote_edit = function() { //$scope.privateNoteEditState = $scope.privateNoteEditState == true ? false : true; $scope.flag.showDelete=!$scope.flag.showDelete; $scope.privateNoteEditState = !$scope.privateNoteEditState if ($scope.privateNoteEditState == true) { $scope.privateNoteEditAndCancel = "取消"; } else { $scope.privateNoteEditAndCancel = "编辑"; } }; //选择取消 $scope.noteChecked = function(privateNote) { privateNote.checked = !privateNote.checked; //alert(privateNote.checked); }; $scope.allSelectOrNot = "全选"; //$scope.allSelectMode = false; //全选 $scope.selectAll =function(){ for(var i =0 ; i<$scope.privateNoteList.length;i++){ $scope.privateNoteList[i].checked =true; //alert( $scope.privateNoteList[i].checked); } } //删除 $scope.deleteAll =function(){ for(var i =0 ; i<$scope.privateNoteList.length;i++){ if($scope.privateNoteList[i].checked ===true){ //alert($scope.privateNoteList[i].checked +$scope.privateNoteList[i].title); $scope.privateNoteList.splice(i,1); i--; } } //return $scope.privateNoteList.splice(i,1); } } ])
注释: