我基本上有这个按钮
<a class="btn btn-primary" ng-click="isPrivate = !isPrivate">
{{isPrivate ? "Make Event Public" : "Make Event Private"}}
</a>
我想拥有它,所以点击按钮会将true false传递给控制器。我试过这个
<a ng-model="event.public" class="btn btn-primary" ng-click="isPrivate = !isPrivate">
{{isPrivate ? "Make Event Public" : "Make Event Private"}}
</a>
任何想法我做错了什么?
继承控制器中的代码
$scope.event.public = '';
我发现我可以使用复选框
这样做<input type="checkbox" id="public" ng-click="isPrivate = !isPrivate" ng-model="event.public"
ng-true-value="'YES'" ng-false-value="'NO'">
我更喜欢它只是一个按钮而不是复选框