ionic1 ion-tabs select

4833 단어

  
    
    
    Inline Tabs

    
    
  
  
    
    

      
        
        
          
          

Tasks

{{item.title}}

Deadlines

Deadlines

Settings

Settings

<div id="task-view" class="modal slide-in-up" ng-controller="TaskCtrl"> <header class="bar bar-header bar-secondary"> <h1 class="title">New Task</h1> <button class="button button-clear button-primary" ng-click="close()">Done</button> </header> <ion-content class="padding has-header"> <input type="text" placeholder="I need to do this..."> </ion-content> </div>

  
angular.module('ionicApp', ['ionic'])

.controller('RootCtrl', function($scope, $ionicTabsDelegate, $timeout ) {
  
  $timeout( function() {
    $ionicTabsDelegate .select(2, false);
    
  },400);

  console.log('RootCtrl');
  $scope.onControllerChanged = function(oldController, oldIndex, newController, newIndex) {
    console.log('Controller changed', oldController, oldIndex, newController, newIndex);
    console.log(arguments);
  };
})


.controller('HomeCtrl', function($scope, $timeout, $ionicModal, $ionicActionSheet) {
  $scope.items = [];

  $ionicModal.fromTemplateUrl('newTask.html', function(modal) {
    $scope.settingsModal = modal;
  });

  var removeItem = function(item, button) {
    $ionicActionSheet.show({
      buttons: [],
      destructiveText: 'Delete Task',
      cancelText: 'Cancel',
      cancel: function() {
        return true;
      },
      destructiveButtonClicked: function() {
        $scope.items.splice($scope.items.indexOf(item), 1);
        return true;
      }
    });
  };

  var completeItem = function(item, button) {
    item.isCompleted = true;
  };

  $scope.onReorder = function(el, start, end) {
    ionic.Utils.arrayMove($scope.items, start, end);
  };

  $scope.onRefresh = function() {
    console.log('ON REFRESH');

    $timeout(function() {
      $scope.$broadcast('scroll.refreshComplete');
    }, 1000);
  }


  $scope.removeItem = function(item) {
    removeItem(item);
  };

  $scope.newTask = function() {
    $scope.settingsModal.show();
  };

  // Create the items
  for(var i = 0; i < 25; i++) {
    $scope.items.push({
      title: 'Task ' + (i + 1),
      buttons: [{
        text: 'Done',
        type: 'button-success',
        onButtonClicked: completeItem,
      }, {
        text: 'Delete',
        type: 'button-danger',
        onButtonClicked: removeItem,
      }]
    });
  }

})

.controller('TaskCtrl', function($scope) {
  $scope.close = function() {
    $scope.modal.hide();
  }
});

  
다음으로 전송:https://www.cnblogs.com/zhangyuefen/p/7683327.html

좋은 웹페이지 즐겨찾기