2015-10-19 18 views
-1

當我將鼠標懸停在按鈕上時,我有該數據=「測試」按鈕我想在{{詳細}}中顯示單詞測試時顯示單詞測試{{詳細}}應該顯示沒有。角度鼠標懸停顯示數據標記

</head> 
    <body ng-app=""> 
    <button ng-mouseover="Detail = data" data="test" >MouseOver Me</button> 
    Details: {{Detail}} 
    </body> 
</html> 
+0

試NG-的init = 「數據= '測試'」 – katmanco

+0

這並不讓我感動沿位,但是當我鼠標移出從按鈕{{詳細}}仍然顯示「測試「 – Bill

+0

然後嘗試使用ng-leave來達到您的目的...在ng-leave data =」「中不會顯示數據。 – katmanco

回答

1
<button ng-mouseover="Detail = data" ng-mouseleave="Detail=''" ng-init="data='test'" > 
0
i think this code is useful for you 

<!DOCTYPE html> 
<html> 
<head> 
    <title></title> 
    <meta charset="utf-8" /> 
    <script src="Scripts/angular.js"></script> 
    <script> 
     var app = angular.module('myApp', []); 
     app.controller('MyCtrl', function ($scope) { 
      $scope.data="test" 
      $scope.hoverIn = function() { 
       this.hoverEdit = true; 
      }; 

      $scope.hoverOut = function() { 
       this.hoverEdit = false; 
      }; 
     }) 
    </script> 
</head> 
<body ng-app="myApp" ng-controller="MyCtrl" > 
    <button ng-mouseover="hoverIn()" ng-mouseleave="hoverOut()" title="{{data}}">MouseOver Me</button> 
    Details: <span ng-show="hoverEdit">{{data}}</span> 
</body> 
</html>