在角度分割窗格中触发一个函数

时间:2017-03-06 16:03:14

标签: angularjs jsplitpane

我在Angular项目中使用angular-split-pane这里是GitHub链接,angular-split link

angular.module('example', ['shagstrom.angular-split-pane'])
  .controller('MainCtrl', function($scope) {
    $scope.splitPaneProperties = {};
    $scope.setFirstComponent = function(value) {
      $scope.splitPaneProperties.firstComponentSize = value;
    };
    $scope.setLastComponent = function(value) {
      $scope.splitPaneProperties.lastComponentSize = value;
    };
  });
html,
body {
  height: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
}


/* The styling below is very simple. You can style things your own way. */

body {
  box-sizing: border-box;
  background: #aaa;
  padding: 5px;
}

.split-pane-divider {
  background: #aaa;
}

.split-pane-component {
  background: #fff;
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>Fixed left</title>
  <link rel="stylesheet" href="../bower_components/split-pane/split-pane.css" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
  <script src="../bower_components/split-pane/split-pane.js"></script>
  <script src="https://raw.githubusercontent.com/shagstrom/angular-split-pane/master/angular-split-pane.js"></script>

</head>

<body data-ng-app="example" ng-controller="MainCtrl">
  <div data-split-pane data-split-pane-properties="splitPaneProperties">
    <div data-split-pane-component data-width="20em">
      <p>Left</p>
      <p>
        <button data-ng-click="setLastComponent(0)">Collapse right component</button>
      </p>
      <p>Left component size {{splitPaneProperties.firstComponentSize}}px</p>
      <p>Right component size {{splitPaneProperties.lastComponentSize}}px</p>
    </div>
    <div data-split-pane-divider data-width="5px"></div>
    <div data-split-pane-component>
      <p>Right</p>
      <p>
        <button data-ng-click="setFirstComponent(0)">Collapse left component</button>
      </p>
      <p>Left component size {{splitPaneProperties.firstComponentSize}}px</p>
      <p>Right component size {{splitPaneProperties.lastComponentSize}}px</p>
    </div>
  </div>

</body>

我想要做的是,当我移动面板时,我想要触发一个函数我该怎么做呢,有没有人在使用过这个指令之前? 代码:

0 个答案:

没有答案