mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
Toggle sjhit
This commit is contained in:
3
js/ext/angular/src/directive/ionicList.js
vendored
3
js/ext/angular/src/directive/ionicList.js
vendored
@ -33,6 +33,7 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
|
||||
return {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
transclude: true,
|
||||
scope: {
|
||||
isEditing: '=',
|
||||
items: '=',
|
||||
@ -52,6 +53,8 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate'])
|
||||
if(attr.animation) {
|
||||
$element.addClass(attr.animation);
|
||||
}
|
||||
|
||||
$element.append(transclude($scope));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
35
js/ext/angular/src/directive/ionicToggle.js
vendored
Normal file
35
js/ext/angular/src/directive/ionicToggle.js
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
angular.module('ionic.ui.content', [])
|
||||
|
||||
// The content directive is a core scrollable content area
|
||||
// that is part of many View hierarchies
|
||||
.directive('toggle', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
scope: {},
|
||||
require: '?ngModel',
|
||||
template: '<div class="toggle">' +
|
||||
' <input type="checkbox">'+
|
||||
' <div class="track">' +
|
||||
' <div class="handle"></div>' +
|
||||
'</div>',
|
||||
|
||||
link: function($scope, $element, $attr, ngModel) {
|
||||
var checkbox;
|
||||
|
||||
$scope.toggle = new ionic.views.Toggle({ el: $element[0] });
|
||||
|
||||
if(!ngModel) { return; }
|
||||
|
||||
checkbox = $element.children()[0];
|
||||
|
||||
if(!checkbox) { return; }
|
||||
|
||||
ngModel.$render = function() {
|
||||
checkbox.checked = ngModel.$viewValue;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user