javascript - How to get Angular to toggle on a button and toggle off the other? -
really simple objective cannot seem work. have 2 toggles (using ionic css) represent 2 modes. 1 mode can on @ time, when toggle 1 on, other should turn off (visually , in code).
i have binded toggles ng-model
, ng-click
, not working. toggles like:
<input type="checkbox" ng-click='turnonac(true)' ng-model='ac'> <input type="checkbox" ng-click='turnonfan(true)' ng-model='fan'>
so when turnonac(true)
called, should set $scope.ac = true
, $scope.fan = false
.
$scope.turnonac = function(bool){ if(bool == true){ $scope.fan = false; $scope.ac = true; } };
it must silly forgetting, blind it! me out?
you didn't inject $scope
in controller function. should inject $scope
, should working fine.
app.controller('navcontroller', function ($scope) {
and if don't use this
in controller may no need use controller as
so use
<div class="nav" ng-controller="navcontrolle">
instead of
<div class="nav" ng-controller="navcontroller nav">
Comments
Post a Comment