Skip to content

Instantly share code, notes, and snippets.

@maca88
Created October 8, 2014 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maca88/20c1d2790b07cf02d579 to your computer and use it in GitHub Desktop.
Save maca88/20c1d2790b07cf02d579 to your computer and use it in GitHub Desktop.
export class Login extends common.Controller {
private dataContext: any;
private userRepo: app.common.repositories.IUserRepository;
static $inject: string[] = ["$scope", "defaultCulture", "dataContext"];
constructor($scope, defaultCulture: string, dataContext: common.services.IDataContext) {
super($scope);
this.dataContext = dataContext.createEmptyCopy();
this.userRepo = this.dataContext.user;
this.dataContext.remoteQuery("GetRegisteredCultures").then(this.culturesLoaded.bind(this));
this.model = this.dataContext.loginModel.createNew();
this.selectedCulture = defaultCulture;
$scope.$watch(() => this.selectedCulture, this.languageChanged.bind(this));
}
public cultures: string[];
public selectedCulture: string = null;
public login() {
if (!this.model.entityAspect.validateEntity()) {
console.log('error');
return;
}
console.log('valid');
this.userRepo.logOn(this.model).then(data => {
console.log(data);
});
}
private culturesLoaded(data: string[]) {
this.cultures = data;
}
private languageChanged(newVal: string, oldVal: string) {
console.log('changed:' + newVal);
console.log(this.selectedCulture);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment