首页 > Angularjs ng-show not working

Angularjs ng-show not working

html:
<div ng-show="showAllApp" class="ng-hide" style="margin-top:20px"></div>

//一个开关
<ion-toggle ng-model="showJoinApp.checked" ng-change="show()">

                    显示

</ion-toggle>

js

$scope.showAllApp = true;

$scope.show = function() {

        console.log('showChange', $scope.showJoinApp.checked);
        $scope.showAllApp = $scope.showJoinApp.checked;
        console.log("showAllApp", $scope.showAllApp);

};

console 正常 前端showAllApp的值却是一直为true ?


在对 $scope.showAllApp赋值的时候 不要直接那么赋
$scope.showAllApp = $scope.showJoinApp.checked?true:false;
关于为什么 我不知道怎么表达 你可以先试试


console.log正常是说$scope.showAllApp在show方法里是正常,能等于true或者false? 而页面上的隐藏显示不起作用?
如果是这样的话,你可以把整个show方法删掉,没必要。直接showAllApp等于ion-toggle的ng-model就行了。你上边的代码可能在某些地方把$scope.showJoinApp.checked弄成了字符串了,所以一直是true。class也不要用ng-hide,这是大忌讳。自己定义变量不要用ng-开头,

【热门文章】
【热门文章】