0
我爲我的應用程序創建自定義複選框指令,但是,選項卡跳過它。我如何強制Tab鍵停止在我的指令?如何在我的AngularJS指令中強制使用製表符?
代碼:(注:Plunker似乎是弗裏茨現在...)
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div ng-controller='TestCtrl'>
<input type='text' />
<test-checkbox ng-model='isChecked'></test-checkbox>
<input type='text' />
</div>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
<script>
var app = angular.module("testApp", []);
app.controller('TestCtrl', ['$scope', function($scope) {
$scope.isChecked = true;
}]);
app.directive('testCheckbox', ['$compile', function ($compile) {
return {
restrict: 'E',
scope: {
isChecked: "=ngModel"
},
link: function (scope, element) {
var html =
"<div class='slgCheckbox' ng-click='onClick(isChecked = !isChecked)'>" +
$(element).html() +
"<i class='checkboxIcon glyphicon' ng-class='{\"glyphicon-check\" : isChecked === true, \"glyphicon-unchecked\" : isChecked === false }'></i>" +
"</div>";
var compiledHtml = $compile(html)(scope);
$(element).replaceWith(compiledHtml);
}
}
}]);
</script>
</body>
</html>
請發佈您的代碼 – 2015-02-08 04:46:06