Created
February 22, 2019 09:34
-
-
Save kevinramharak/122f7b9df021997343dc9813189b1609 to your computer and use it in GitHub Desktop.
simple angularjs component test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script data-require="angular.js@1.7.0" data-semver="1.7.0" src="https://code.angularjs.org/1.7.0/angular.min.js"></script> | |
<script src="https://gitcdn.link/repo/kevinramharak/ng-sane-defaults/master/dist/ng-sane-defaults.js"></script> | |
<link rel="stylesheet" href="style.css" /> | |
<script> | |
function KInputController() { | |
} | |
KInputController.prototype.$defaults = { | |
placeholder: "", | |
type: 'text' | |
}; | |
KInputController.prototype.$onInit = function $onInit() { | |
console.log(this); | |
} | |
angular.module('app', ['ng-sane-defaults']).component('kInput', { | |
template: '<input type="{{ $ctrl.type }}" placeholder="{{ $ctrl.placeholder }}" />', | |
controller: KInputController, | |
require: { | |
model: 'ngModel' | |
}, | |
bindings: { | |
placeholder: '<?', | |
type: "<?" | |
} | |
}); | |
</script> | |
</head> | |
<body ng-app="app"> | |
<k-input ng-model="" placeholder="'Placeholder'"></k-input> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment