Angularjs 自举开关与ng模型
我在应用程序中使用angular和引导开关插件。它的工作原理如下:Angularjs 自举开关与ng模型,angularjs,angular-ui-bootstrap,bootstrap-switch,Angularjs,Angular Ui Bootstrap,Bootstrap Switch,我在应用程序中使用angular和引导开关插件。它的工作原理如下: <input type="checkbox" name="my-checkbox" checked> <script>$("[name='my-checkbox']").bootstrapSwitch("size", "small");</script> <input type="checkbox" name="my-checkbox" checked="variableStatus"
<input type="checkbox" name="my-checkbox" checked>
<script>$("[name='my-checkbox']").bootstrapSwitch("size", "small");</script>
<input type="checkbox" name="my-checkbox" checked="variableStatus" data-on-color="success" data-off-color="warning">
or
<input type="checkbox" name="my-checkbox" ng-model="variableStatus" data-on-color="success" data-off-color="warning">
$(“[name='my-checkbox']”)。引导开关(“大小”、“小”);
问题是,如果我想使用我发现的所有属性,它就不起作用
如何在交换机上使用ng型号?
我想这样使用它:
<input type="checkbox" name="my-checkbox" checked>
<script>$("[name='my-checkbox']").bootstrapSwitch("size", "small");</script>
<input type="checkbox" name="my-checkbox" checked="variableStatus" data-on-color="success" data-off-color="warning">
or
<input type="checkbox" name="my-checkbox" ng-model="variableStatus" data-on-color="success" data-off-color="warning">
或
它不起作用的最明显原因是引导开关是一个jQuery库。Angular不能很好地使用jQuery,因此如果您想使用它,就必须编写自己的指令。但是,下面的链接将为您提供一个有人编写的名为angular bootstrap switch的指令。你可能想看看
引导程序有特殊的启动方法,如果您想启动它,请在angularjs中的一段时间后尝试启动
setTimeout(installSwitcher,1000);
函数installSwitcher(){
$(“[name='my-checkbox']”)。bootstrapSwitch();
}