如何在条件下显示锚标签,当点击锚显示内容时,不是(新的角度)?

时间:2018-03-29 09:47:03

标签: javascript html angularjs

我已经使用ng-show制作锚标签以显示条件。如何处理点击锚点并显示内容

 <span><a class = "req-clickable" ng-show = "vm.inScopeServicesListLength >= 6">+{{vm.moreInscopeServices}}more</a> 
                <span>

1 个答案:

答案 0 :(得分:1)

点击更多

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl as vm">

<span><a class= "req-clickable" ng-click="vm.increase()" ><span  ng-show = "vm.inScopeServicesListLength >= 1">+{{vm.moreInscopeServices}} </span>more</a><span>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    var vm = this;
    vm.inScopeServicesListLength = 0;
    vm.moreInscopeServices = 'NEW' ;
    vm.increase = function(){
     vm.inScopeServicesListLength++;
    };

});
</script>

</body>
</html>