diff --git a/imports/ui/components/register/register.js b/imports/ui/components/register/register.js new file mode 100644 index 000000000..ab4ae9479 --- /dev/null +++ b/imports/ui/components/register/register.js @@ -0,0 +1,58 @@ +import angular from 'angular'; +import angularMeteor from 'angular-meteor'; +import uiRouter from 'angular-ui-router'; + +import { Accounts } from 'meteor/accounts-base'; + +import template from './register.html'; + +class Register { + constructor($scope, $reactive, $state) { + 'ngInject'; + + this.$state = $state; + + $reactive(this).attach($scope); + + this.credentials = { + email: '', + password: '' + }; + + this.error = ''; + } + + register() { + Accounts.createUser(this.credentials, + this.$bindToContext((err) => { + if (err) { + this.error = err; + } else { + this.$state.go('parties'); + } + }) + ); + } +} + +const name = 'register'; + +// create a module +export default angular.module(name, [ + angularMeteor, + uiRouter +]) + .component(name, { + template, + controllerAs: name, + controller: Register + }) + .config(config); + +function config($stateProvider) { + 'ngInject'; + $stateProvider.state('register', { + url: '/register', + template: '' + }); +}