A Pen by Victor Yan
How do I make an a pen by victor yan?
What is a a pen by victor yan? How do you make a a pen by victor yan? This script and codes were developed by Victor Yan on 05 January 2023, Thursday.
A Pen by Victor Yan - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>A Pen by Victor Yan</title> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>
</head>
<body> <div class="container">
<div class="ng-scope" ng-app="app" ng-controller="Ctrl1"> <div class="col-xs-12 col-sm-6"> <h3>Multi Checkbox List Demo</h3> <div class="well"><!-- ngRepeat: role in roles -->
<label ng-repeat="role in roles"> <input type="checkbox" checklist-model="user.roles" checklist-value="role"> {{role}}
</label> </div>
<div>
<h3>Selected User Roles </h3>
<pre class="ng-binding">{{user.roles|json}}</pre>
</div> <div>Provided by <a onclick="window.open('https://www.tipsoftheday.com.au')">Tips of the day</a></div> </div> <script src='https://code.angularjs.org/1.2.22/angular.js'></script> <script src="js/index.js"></script>
</body>
</html>
A Pen by Victor Yan - Script Codes JS Codes
/** * Checklist-model * AngularJS directive for list of checkboxes */
angular.module('checklist-model', [])
.directive('checklistModel', ['$parse', '$compile', function($parse, $compile) { // contains function contains(arr, item) { if (angular.isArray(arr)) { for (var i = 0; i < arr.length; i++) { if (angular.equals(arr[i], item)) { return true; } } } return false; } // add function add(arr, item) { arr = angular.isArray(arr) ? arr : []; for (var i = 0; i < arr.length; i++) { if (angular.equals(arr[i], item)) { return arr; } } arr.push(item); return arr; } // remove function remove(arr, item) { if (angular.isArray(arr)) { for (var i = 0; i < arr.length; i++) { if (angular.equals(arr[i], item)) { arr.splice(i, 1); break; } } } return arr; } // http://stackoverflow.com/a/19228302/1458162 function postLinkFn(scope, elem, attrs) { // compile with `ng-model` pointing to `checked` $compile(elem)(scope); // getter / setter for original model var getter = $parse(attrs.checklistModel); var setter = getter.assign; // value added to list var value = $parse(attrs.checklistValue)(scope.$parent); // watch UI checked change scope.$watch('checked', function(newValue, oldValue) { if (newValue === oldValue) { return; } var current = getter(scope.$parent); if (newValue === true) { setter(scope.$parent, add(current, value)); } else { setter(scope.$parent, remove(current, value)); } }); // watch original model change scope.$parent.$watch(attrs.checklistModel, function(newArr, oldArr) { scope.checked = contains(newArr, value); }, true); } return { restrict: 'A', priority: 1000, terminal: true, scope: true, compile: function(tElement, tAttrs) { if (tElement[0].tagName !== 'INPUT' || !tElement.attr('type', 'checkbox')) { throw 'checklist-model should be applied to `input[type="checkbox"]`.'; } if (!tAttrs.checklistValue) { throw 'You should provide `checklist-value`.'; } // exclude recursion tElement.removeAttr('checklist-model'); // local scope var storing individual checkbox model tElement.attr('ng-model', 'checked'); return postLinkFn; } };
}]);
var app = angular.module("app", ["checklist-model"]);
app.controller('Ctrl1', function($scope) { $scope.roles = [ 'guest', 'user', 'customer', 'admin' ]; $scope.user = { roles: ['user'] }; $scope.checkAll = function() { $scope.user.roles = angular.copy($scope.roles); }; $scope.uncheckAll = function() { $scope.user.roles = []; }; $scope.checkFirst = function() { $scope.user.roles.splice(0, $scope.user.roles.length); $scope.user.roles.push('guest'); };
});
Developer | Victor Yan |
Username | tipsoftheday |
Uploaded | January 05, 2023 |
Rating | 3 |
Size | 2,757 Kb |
Views | 6,072 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Make element focusable using tabindex | 1,593 Kb |
HTML 5 Local Storage Example | 1,912 Kb |
HTML 5 Session Storage Example | 1,825 Kb |
Tooltip using Bootstrap | 2,452 Kb |
QUnit example to verify calculate age function | 2,692 Kb |
Bootstrap 3 button groups | 1,510 Kb |
Disable And Enable Input Elements In A Div Block Using jQuery | 2,033 Kb |
Navigation menu using Angular Directive | 2,391 Kb |
Tooltip using plain Javascript | 1,825 Kb |
TodoMVC using AngularJS | 6,551 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Calculator | Rzencoder | 4,572 Kb |
Sticky div | Kaslab | 2,225 Kb |
AOR site logo | Thatbram | 2,527 Kb |
Video mute | Leon9208 | 2,131 Kb |
TweetBox with React JS | J0zelito | 3,325 Kb |
Nested table email layout | Massimo-cassandro | 2,355 Kb |
Client-side Email Validation | Collizo4sky | 1,538 Kb |
Multi-step GSAP animation | Acacheung | 2,668 Kb |
Mobile Nav Menu | AliKlein | 4,745 Kb |
Headroom.js demo | WickyNilliams | 3,982 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!