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