带有$ watch的Angular材质

时间:2016-11-03 21:39:05

标签: angularjs angular-material

hive> add jar /home/me/gis-tools-for-hadoop/samples/lib/esri-geometry-api.jar;
Added [/home/me/gis-tools-for-hadoop/samples/lib/esri-geometry-api.jar] to class path
Added resources: [/home/me/gis-tools-for-hadoop/samples/lib/esri-geometry-api.jar]
hive> add jar /home/me/gis-tools-for-hadoop/samples/lib/spatial-sdk-hadoop.jar;
Added [/home/me/gis-tools-for-hadoop/samples/lib/spatial-sdk-hadoop.jar] to class path
Added resources: [/home/me/gis-tools-for-hadoop/samples/lib/spatial-sdk-hadoop.jar]
hive> create temporary function ST_GeodesicLengthWGS84 AS 'com.esri.hadoop.hive.ST_GeodesicLengthWGS84';
OK
Time taken: 0.014 seconds
hive> create temporary function ST_SetSRID AS 'com.esri.hadoop.hive.ST_SetSRID';
OK
Time taken: 0.008 seconds
hive> create temporary function ST_LineString AS 'com.esri.hadoop.hive.ST_LineString';

SELECT * FROM mytable WHERE ST_GeodesicLengthWGS84(ST_SetSRID(ST_LineString(latitude_of_center, longitude_of_center, latitude_of_point, longitude_of_point), 4326)) <= 8046.72

我想动态更新控制器的 md-position-mode md-offset值。 但它只在页面加载时才第一次工作。

如何在更改值时更新并生效?!

1 个答案:

答案 0 :(得分:-1)

首先查看整页视图中的代码段,它位于&#34;运行代码段&#34;的右侧。点击&#34;运行代码段&#34;然后点击&#34;整页&#34;

  1. 0 -5更改为0 50向下移动
  2. 0 -5更改为50 -5向右移动
  3. target target更改为target-right target,将0 -5更改为""菜单位于右侧
  4. mdMenu

    &#13;
    &#13;
    var myApp = angular.module('myApp', ['ngMaterial']);
    
    myApp.controller('myController',
      function myController($scope, $mdDialog){
      $scope.vm = {
       "position": "target target",
        "offset": "0 -5"
      };
      
      var originatorEv;
      $scope.openMenu = function($mdOpenMenu, ev) {
          originatorEv = ev;
          $mdOpenMenu(ev);
        };
      
      $scope.announceClick = function(index) {
          $mdDialog.show(
            $mdDialog.alert()
              .title('You clicked!')
              .textContent('You clicked the menu item at index ' + index)
              .ok('Nice')
              .targetEvent(originatorEv)
          );
          originatorEv = null;
        };
      
    });
    &#13;
    .menudemoMenuPositionModes .md-menu-demo {
      padding: 24px; }
    
    .menudemoMenuPositionModes .menu-demo-container {
      min-height: 200px; }
    &#13;
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
    <!-- Angular Material requires Angular.js Libraries -->
      <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
      <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
      <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
      <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>
    
    <div ng-app="myApp">
      <div ng-controller='myController'>
        Position: <input type="text" name="position" ng-model="vm.position">
        Offset: <input type="text" name="offset" ng-model="vm.offset">
        <p>$scope.vm = {{ vm | json }};</p>
        
          <div layout="column" flex-xs="100" flex-sm="100" flex="33" layout-align="center center">
            <p>Target mode with <code>md-offset</code></p>
            <md-menu md-position-mode="{{vm.position}}" md-offset="{{vm.offset}}">
              <md-button class="md-raised md-primary" aria-label="Open demo menu" ng-click="openMenu($mdOpenMenu, $event)">
                Open
              </md-button>
              <md-menu-content width="4">
                <md-menu-item ng-repeat="item in [1, 2]">
                  <md-button ng-click="announceClick($index)"> <span md-menu-align-target>Option</span> {{item}} </md-button>
                </md-menu-item>
              </md-menu-content>
            </md-menu>
          </div>
        
      </div>
    </div>
    &#13;
    &#13;
    &#13;