gpt4 book ai didi

javascript - AngularJS:ui-开关位置(开/关)识别

转载 作者:行者123 更新时间:2023-11-28 00:00:57 25 4
gpt4 key购买 nike

我在识别 .js 文件中的 ui-switch 位置(真/假)时遇到了一些问题..

我的 .html 文件 ui-switch:

<ui-switch ng-model='onOff'></ui-switch>

我的页面 Controller :

app.controller('tController', function($scope){
// I would like to get my switch position here :[
});

提前致谢!

最佳答案

终于可以用了。我的方法是将 ng-click 添加到我的 ui-switch 中:

<ui-switch ng-model='onOff' ng-click="buttonPosition();"></ui-switch>

在我的 Controller 中,我添加了以下内容:

$scope.buttonPosition = function(){
var onOff = $scope.onOff;
console.log(Boolean(onOff));
}

这给了我真/假。希望它对其他人有帮助。

关于javascript - AngularJS:ui-开关位置(开/关)识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31813264/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com