Angular mouseover显示数据标记

时间:2015-10-19 07:51:29

标签: angularjs

我有这个按钮,数据=" test"当我将鼠标悬停在按钮上时,我想在{{Detail}}中显示单词test,当我从按钮{{Detail}}鼠标移出时,我不想显示任何内容。

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

2 个答案:

答案 0 :(得分:1)

<button ng-mouseover="Detail = data" ng-mouseleave="Detail=''" ng-init="data='test'" >

答案 1 :(得分: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>