Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Step 18.46: Create Register
  • Loading branch information
Kamil Kisiela authored and Dotan Simha committed Nov 22, 2016
1 parent b541ff5 commit 6bdb0d6
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions 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: '<register></register>'
});
}

0 comments on commit 6bdb0d6

Please sign in to comment.