AngularJS Hello World Ctrl
by zfikar
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.5/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
<input type="my-date" ng-model="hi" /> <br> {{hi}}
</div>
CSS
select {
border-radius: 50px;
}
JavaScript
var myApp = angular.module('app', []);
myApp.directive('input', function() {
return {
restrict: 'E',
require: 'ngModel',
link: function(scope, element, attrs, ngModelCtrl) {
console.log(attrs.type);
if (attrs.type === 'my-date') {
element.datepicker({
dateFormat: 'dd MM yy',
changeMonth: true,
changeYear: true,
constrainInput: true
});
attrs.pushattr("border-radius: 0");
};
}
}
})
myApp.controller('ctrl', function($scope) {
$scope.hi = 'Hello world';
});