Skip to content
Permalink
Browse files

Step 4.17: Create profile controller

  • Loading branch information
DAB0mB authored and Dotan Simha committed Apr 3, 2016
1 parent 6edba44 commit 0cad455e354caf10a6c149fbad6515ecfbf98346
Showing with 33 additions and 0 deletions.
  1. +33 −0 client/scripts/controllers/profile.controller.js
@@ -0,0 +1,33 @@
import { _ } from 'meteor/underscore';
import { Controller } from 'angular-ecmascript/module-helpers';

export default class ProfileCtrl extends Controller {
constructor() {
super(...arguments);

const profile = this.currentUser && this.currentUser.profile;
this.name = profile ? profile.name : '';
}

updateName() {
if (_.isEmpty(this.name)) return;

this.callMethod('updateName', this.name, (err) => {
if (err) return this.handleError(err);
this.$state.go('tab.chats');
});
}

handleError(err) {
this.$log.error('Profile save error ', err);

this.$ionicPopup.alert({
title: err.reason || 'Save failed',
template: 'Please try again',
okType: 'button-positive button-clear'
});
}
}

ProfileCtrl.$name = 'ProfileCtrl';
ProfileCtrl.$inject = ['$state', '$ionicPopup', '$log'];

0 comments on commit 0cad455

Please sign in to comment.
You can’t perform that action at this time.