在controller中定义了点击函数——一个布尔值的取反,把返回的布尔值绑定在ng-show上,在click时运行函数,不能正常的显示隐藏,代码如下
`
HTML:
Overview
Organization Roster
Customer Rollup
Operational Dashboard
Overview
Organization Roster
Customer Rollup
Opportunity Tracker
JS:
.controller("siderbarCtrl",["$scope",function($scope){
$scope.Financial_show=false;
$scope.Operational_show=true;
$scope.Opportunity_show=false;
$scope.show=function(ele){
return $scope.ele=!$scope.ele;
}}]);
下面的代码可以正常的显示隐藏:
HTML:
Overview
Organization Roster
Customer Rollup
Operational Dashboard
Overview
Organization Roster
Customer Rollup
Opportunity Tracker
JS:
.controller("siderbarCtrl",["$scope",function($scope){
$scope.Financial_show=false;
$scope.Operational_show=true;
$scope.Opportunity_show=false;
}]);
初学者请前辈们指点,指点~~
`
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
ng-click='show()'
$scope.show=function(){
}
不需要传递参数,直接在定义的show函数里面控制绑定的那个值。你之前传递过去的参数赋予的那个值ele也没有初始化。