Angularjs 如何根据其他元素的真实值选择按钮组项目?

Angularjs 如何根据其他元素的真实值选择按钮组项目?,angularjs,angular-ui-bootstrap,Angularjs,Angular Ui Bootstrap,我有一个自定义指令切换开关 实现这一目标的正确方法是什么?正如您所看到的,我已经能够禁用其他两项,但我不知道如何选择中间的一项。现在我在控制器中放置了一块手表。我不确定我是否喜欢这个,但在更好的解决方案出现之前,它是可以的 $scope.$watch('isModule', function (oldValue, newValue) { if ((oldValue != null) && newValue) { $scope.media.mediaType

我有一个自定义指令切换开关


实现这一目标的正确方法是什么?正如您所看到的,我已经能够禁用其他两项,但我不知道如何选择中间的一项。

现在我在控制器中放置了一块手表。我不确定我是否喜欢这个,但在更好的解决方案出现之前,它是可以的

$scope.$watch('isModule', function (oldValue, newValue) {
    if ((oldValue != null) && newValue) {
        $scope.media.mediaType = 1;
    }
});
<div class="form-group">
    <label class="col-sm-2 control-label">Media Type</label>
    <div class="col-sm-10">
        <div class="btn-group">
            <label class="btn btn-default" ng-model="media.mediaType" btn-radio="0" ng-disabled="(!isModule)">Audio</label>
            <label class="btn btn-default" ng-model="media.mediaType" btn-radio="1" >Video</label>
            <label class="btn btn-default" ng-model="media.mediaType" btn-radio="2" ng-disabled="(!isModule)">Text</label>
        </div>
    </div>
</div>
$scope.$watch('isModule', function (oldValue, newValue) {
    if ((oldValue != null) && newValue) {
        $scope.media.mediaType = 1;
    }
});