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,648 |
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 |
AngularJS BootStrap 3 Modal Dialogs | 3,848 Kb |
NgRepeat with Controller As Test | 2,482 Kb |
AngularJS Floating Menu | 4,071 Kb |
Dragging in AngularJS | 2,859 Kb |
Course Layout in Angular Material | 16,237 Kb |
Edit User Details in Dialog | 3,211 Kb |
AngularJS Draggable Directive | 3,506 Kb |
Sass Bourbon Tests | 2,615 Kb |
AngularJS Dialog Service, with i18n | 5,197 Kb |
Testing CSS Animations | 1,937 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 |
IPhone5S SVG Space Grey | Onlinechris | 75,035 Kb |
Twitch | SarahDunlap | 2,937 Kb |
A Pen by Michael Parenteau | Michaelparenteau | 2,133 Kb |
Header Line Issue | Charlie-volpe | 1,768 Kb |
A Pen by Jonas Bjork | Jonasbjork | 3,115 Kb |
Drop Cap | Gsaiki | 1,571 Kb |
MAD9013 - Float Images with Content | Mad-d | 2,220 Kb |
Drill-down Map | Good886 | 8,484 Kb |
Console fun | Dviate | 1,500 Kb |
Button fills | Zubfatal | 5,205 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!