Javascript Angularjs使用ng单击显示更多省略号文本
我试图用“…更多”文本显示div内容的省略号。我还尝试使用ng click来显示单击“……更多”时的全文 我尝试的是在单击时添加一个悬停类,但在连接单击事件以显示更多文本时出现问题Javascript Angularjs使用ng单击显示更多省略号文本,javascript,css,angularjs,ellipsis,Javascript,Css,Angularjs,Ellipsis,我试图用“…更多”文本显示div内容的省略号。我还尝试使用ng click来显示单击“……更多”时的全文 我尝试的是在单击时添加一个悬停类,但在连接单击事件以显示更多文本时出现问题 钱德拉和他美丽的妻子在办公室,脸上涂着酸奶油。 var myApp=angular.module('myApp',[]); 函数MyCtrl($scope){ $scope.class=“appEllipseContent”; $scope.showEllipseContent=function(){ 如果($s
钱德拉和他美丽的妻子在办公室,脸上涂着酸奶油。
var myApp=angular.module('myApp',[]);
函数MyCtrl($scope){
$scope.class=“appEllipseContent”;
$scope.showEllipseContent=function(){
如果($scope.class==“appEllipseContent”)
$scope.class=“”;
其他的
$scope.class=“appEllipseContent”;
};
}
.外观经济{
溢出:隐藏;
空白:nowrap;
-ms文本溢出:省略号;
文本溢出:省略号;
宽度:200px;
}
.appEllipseContent:悬停{
溢出:可见;
空白:正常;
}
使用ng类和ng一起单击以应用基于布尔值的类,如下所示:
index.html
<!DOCTYPE html>
<html ng-app>
<head>
<script data-require="angular.js@1.3.0" data-semver="1.5.0" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="script.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div ng-class="{'appEllipseContent': !isActive, 'appEllipseContenthover': isActive}"
ng-click="isActive = !isActive">
Chandra is in office with his beautiful wife with sour cream on her face.
</div>
</body>
</html>
下面是一个。使用ng类并将ng单击在一起,以应用基于布尔值的类,如下所示: index.html
<!DOCTYPE html>
<html ng-app>
<head>
<script data-require="angular.js@1.3.0" data-semver="1.5.0" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="script.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div ng-class="{'appEllipseContent': !isActive, 'appEllipseContenthover': isActive}"
ng-click="isActive = !isActive">
Chandra is in office with his beautiful wife with sour cream on her face.
</div>
</body>
</html>
这是一个。看看这个,我想这就是你想要的
[http://jsfiddle.net/HB7LU/23727/]
HTML
看看这个,我想这就是你想要的
[http://jsfiddle.net/HB7LU/23727/]
HTML
你问的问题不是很清楚。您想在省略号文本上显示“…更多”,而不是仅显示“…”?您的要求不太清楚。您想在省略号文本上显示“…更多”而不是“…”吗?
<div id= 'divEllipseContainer' ng-mouseover="test2()" class="{{class}}" >
Chandra is in office with his beautiful wife with sour cream on her face.
</div><a ng-hide="test" ng-mouseleave="test2()" ng-click="showEllipseContent()">...more</a>
</div>
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.class = "appEllipseContent";
$scope.test = true;
$scope.showEllipseContent = function(){
if ($scope.class == "appEllipseContent")
$scope.class = "";
else
$scope.class = "appEllipseContent";
};
$scope.test2 = function(){
if ($scope.test)
$scope.test = false;
else
$scope.test = true;
};
}