Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 自举开关与ng模型_Angularjs_Angular Ui Bootstrap_Bootstrap Switch - Fatal编程技术网

Angularjs 自举开关与ng模型

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"

我在应用程序中使用angular和引导开关插件。它的工作原理如下:

<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();
}