i399exng1comp/app/switch.cmp.js

31 lines
572 B
JavaScript

(function () {
'use strict';
var options = {
templateUrl: 'app/switch.cmp.html',
controller: Controller,
bindings: {
onChange: '=',
initial: '<'
}
};
function Controller() {
this.toggle = toggle;
this.$onInit = $onInit;
function $onInit() {
this.isOn = this.initial;
}
function toggle() {
this.isOn = !this.isOn;
this.onChange(this.isOn);
}
}
angular.module('app').component('switch', options);
})();