Skip to content

Instantly share code, notes, and snippets.

@kevinramharak
Created February 22, 2019 09:34
Show Gist options
  • Save kevinramharak/122f7b9df021997343dc9813189b1609 to your computer and use it in GitHub Desktop.
Save kevinramharak/122f7b9df021997343dc9813189b1609 to your computer and use it in GitHub Desktop.
simple angularjs component test
<!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