搜尋

首頁  >  問答  >  主體

angular.js - angularJS最簡單方法實作點擊checkbox,button變亮

在http://www.runoob.com/try/try.php?filena...有個小小的例子,一個按鈕,一個checkbox,我點擊checkbox,然後按鈕disabled,然後按鈕變暗。我想問的是,怎麼通過最簡單的方法,反過來,我點擊checkbox,abled呢?

實例代碼是:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>

<p ng-app="" ng-init="mySwitch=true">
<p>
<button ng-disabled="mySwitch">点我!</button>
</p>
<p>
<input type="checkbox" ng-model="mySwitch"/>按钮
</p>
<p>
{{ mySwitch }}
</p>
</p>
<script>
    
</script>

</body>
</html>
仅有的幸福仅有的幸福2843 天前631

全部回覆(2)我來回復

  • 大家讲道理

    大家讲道理2017-05-15 17:02:25

    不知道是不是這樣?我重新修改了程式碼

    <input type="checkbox" ng-model="mySwitch"/>
    <lable ng-click="mySwitch=!mySwitch">按钮</lable>

    回覆
    0
  • 怪我咯

    怪我咯2017-05-15 17:02:25

    雷雷

    回覆
    0
  • 取消回覆