AngularJS Datalist Directive
How do I make an angularjs datalist directive?
Simple example on how to create an AngularJS directive to automate the creation of an HTML5 datalist form entry. The example also shows how requiring the ngModel controller for a directive works.. What is a angularjs datalist directive? How do you make a angularjs datalist directive? This script and codes were developed by Michael E Conroy on 03 July 2022, Sunday.
AngularJS Datalist Directive - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>AngularJS Datalist Directive</title> <link rel='stylesheet prefetch' href='http://netdna.bootstrapcdn.com/bootswatch/3.1.1/superhero/bootstrap.min.css'>
</head>
<body> <body ng-app='dataList' ng-controller='dataListCtrl'> <angled-datalist list='browsers' ng-model='browser'></angled-datalist> <div class='well'> Choosen: {{browser}} </div>
</body> <script src='http://code.angularjs.org/1.2.17/angular.min.js'></script>
<script src='http://code.angularjs.org/1.2.17/angular-sanitize.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
AngularJS Datalist Directive - Script Codes JS Codes
angular.module('dataList',['ngSanitize'])
.controller('dataListCtrl',['$scope',function($scope){ $scope.browsers = [ { option : 'Google Chrome', value : 'chrome' }, { option : 'Microsoft Internet Explorer', value : 'ie' }, { option : 'Mozilla Firefox', value : 'firefox' }, { option : 'Opera', value : 'opera' }, { option : 'Safari', value : 'safari' } ]; $scope.browser = '';
}]) // end dataListCtrl
.directive('angledDatalist',['$sce',function($sce){ return{ restrict : 'AE', require : '?ngModel', template : '<ng-form name="dlTest"><input list="dl" ng-model="choosen"><datalist id="dl"><select><option ng-repeat="opt in list" label="{{opt.option}}">{{opt.value}}</option></select></datalist></ng-form>', replace : false, scope : { list : '=' }, link : function(scope,element,attrs,ngModel){ if(!ngModel || (scope.list.length <= 0)) return; scope.choosen = ''; scope.$watch('choosen',function(val,old){ ngModel.$setViewValue(val); }); } }; // return
}]); // end angledDatalist

Developer | Michael E Conroy |
Username | m-e-conroy |
Uploaded | July 03, 2022 |
Rating | 3 |
Size | 2,366 Kb |
Views | 54,621 |
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 |
Dragging in AngularJS | 2,859 Kb |
Testing CSS Animations | 1,937 Kb |
AngularJS Windows | 4,665 Kb |
AngularJS Droppable Directive With Dynamic Template | 3,748 Kb |
AngularJS Floating Menu | 4,071 Kb |
AngularJS Draggable Directive | 3,506 Kb |
AngularJS Dialog Service, with i18n | 5,197 Kb |
Sass Bourbon Tests | 2,615 Kb |
Course Layout in Angular Material | 16,237 Kb |
Edit User Details in Dialog | 3,211 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 |
Christ the Redeemer | Prashantsani | 2,208 Kb |
Image Stack Test SCSS | CalvinMorett | 2,799 Kb |
Shape Outside - Polygon | Stacy | 3,954 Kb |
Responsive Menu I | Rodericksandoval | 3,045 Kb |
Hovers with popups | Zacharyolson | 2,380 Kb |
Testing Code Pen | Jduprey | 1,468 Kb |
Smoke Shader - Frame Buffer | Omarshe7ta | 2,672 Kb |
CSS only simple parallax scroll | Stanssongs | 3,708 Kb |
Fading gradient button | Insprd | 1,713 Kb |
Polygon Dodecahedron in CSS | Vennsoh | 7,606 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!