mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
started checkbox
This commit is contained in:
40
js/ext/angular/src/directive/ionicCheckbox.js
vendored
Normal file
40
js/ext/angular/src/directive/ionicCheckbox.js
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
angular.module('ionic.ui.checkbox', [])
|
||||
|
||||
|
||||
.directive('checkbox', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
require: '?ngModel',
|
||||
scope: true,
|
||||
template: '<div class="checkbox"><input type="checkbox"><div class="handle"></div></div>',
|
||||
|
||||
link: function($scope, $element, $attr, ngModel) {
|
||||
var checkbox, handle;
|
||||
|
||||
if(!ngModel) { return; }
|
||||
|
||||
checkbox = $element.children().eq(0);
|
||||
handle = $element.children().eq(1);
|
||||
|
||||
if(!checkbox.length || !handle.length) { return; }
|
||||
|
||||
$scope.checkbox = new ionic.views.Checkbox({
|
||||
el: $element[0],
|
||||
checkbox: checkbox[0],
|
||||
handle: handle[0]
|
||||
});
|
||||
|
||||
$element.bind('click', function(e) {
|
||||
$scope.checkbox.tap(e);
|
||||
$scope.$apply(function() {
|
||||
ngModel.$setViewValue(checkbox[0].checked);
|
||||
});
|
||||
});
|
||||
|
||||
ngModel.$render = function() {
|
||||
$scope.checkbox.val(ngModel.$viewValue);
|
||||
};
|
||||
}
|
||||
}
|
||||
})
|
||||
1
js/ext/angular/src/ionicAngular.js
vendored
1
js/ext/angular/src/ionicAngular.js
vendored
@ -7,6 +7,7 @@ angular.module('ionic.ui', ['ionic.ui.content',
|
||||
'ionic.ui.nav',
|
||||
'ionic.ui.sideMenu',
|
||||
'ionic.ui.list',
|
||||
'ionic.ui.checkbox',
|
||||
'ionic.ui.toggle'
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user