Toggle sjhit

This commit is contained in:
Max Lynch
2013-10-11 12:09:19 -05:00
parent af832c649b
commit 0b375d4eb9
4 changed files with 45 additions and 1 deletions

View File

@ -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));
}
}
}

View 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;
};
}
}
})