Created
October 8, 2014 20:19
-
-
Save maca88/20c1d2790b07cf02d579 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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