angularjs - add an ng-model to ng-click that passes true false params -


i have button

<a class="btn btn-primary" ng-click="isprivate = !isprivate">                     {{isprivate ? "make event public" : "make event private"}}                 </a> 

i'm wanting have button once clicked passes true false controller. i've tried this

<a ng-model="event.public" class="btn btn-primary" ng-click="isprivate = !isprivate">                     {{isprivate ? "make event public" : "make event private"}}                 </a> 

any ideas im doing wrong?

heres code in controller

$scope.event.public = '';

i've found out can checkbox

<input type="checkbox" id="public" ng-click="isprivate = !isprivate" ng-model="event.public"            ng-true-value="'yes'" ng-false-value="'no'"> 

i'd prefer being button though rather checkbox

you don't need ngmodel button. can

$scope.event = {       public : true     } 

here example


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -