-
-
Notifications
You must be signed in to change notification settings - Fork 348
/
login.ts
48 lines (43 loc) · 1.52 KB
/
login.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import {Component} from "angular2/core";
import {Router} from "angular2/router";
import * as dialogsModule from "ui/dialogs";
import {ActionItems} from "ui/action-bar";
import {TextField} from "ui/text-field";
import {UserViewModel} from "../../shared/view-models/user-view-model";
import {ActionBarUtil} from "../../shared/utils/action-bar-util";
import {Config} from "../../shared/config";
@Component({
selector: "login",
templateUrl: "views/login/login.html"
})
export class LoginPage {
user: UserViewModel;
constructor(private router: Router) {
ActionBarUtil.setTitle("Sign In");
ActionBarUtil.emptyActionBarItems();
this.user = new UserViewModel({
email: "nativescriptrocks@telerik.com",
password: "password"
});
}
signIn() {
// Need to manually set these until 2-way data binding is supported
var emailTextField = <TextField>Config.page.getViewById("email");
var passwordTextField = <TextField>Config.page.getViewById("password");
this.user.email = emailTextField.text;
this.user.password = passwordTextField.text;
this.user.login()
.catch((error) => {
dialogsModule.alert({
message: "Unfortunately we could not find your account.",
okButtonText: "OK"
});
})
.then(() => {
this.router.navigate(["List"]);
});
}
register() {
this.router.navigate(["Register"]);
}
}