AngularJS:ui开关位置(ON / OFF)识别

时间:2015-08-04 15:25:51

标签: javascript html angularjs html5 uiswitch

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

我的.html文件ui-switch:

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

我的页面控制器:

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

提前致谢!

1 个答案:

答案 0 :(得分:1)

终于开始工作了。我的方法是我添加了ng-click到我的ui-switch:

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

在我的控制器中,我添加了这个:

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

这给了我真/假。 希望它能帮助别人。

相关问题