Guest User

Untitled

a guest
Feb 28th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. login.component.html
  2. ```html
  3. <FlexboxLayout class="page">
  4. <StackLayout class="form">
  5. <Image class="logo" src="~/images/icon.png"></Image>
  6. <Label class="header" text="Maxanet Uploader"></Label>
  7.  
  8. <StackLayout class="input-field">
  9. <TextField class="input" hint="Email" keyboardType="email" autocorrect="false" autocapitalizationType="none" [(ngModel)]="user.email" returnKeyType="next" (returnPress)="focusPassword()"></TextField>
  10. <StackLayout class="hr-light"></StackLayout>
  11. </StackLayout>
  12.  
  13. <StackLayout class="input-field">
  14. <TextField #password class="input" hint="Password" secure="true" [(ngModel)]="user.password" [returnKeyType]="'done'" (returnPress)="submit()"></TextField>
  15. <StackLayout class="hr-light"></StackLayout>
  16. </StackLayout>
  17.  
  18. <Button [text]="'Log In'" (tap)="submit()" class="btn btn-primary m-t-20"></Button>
  19. </StackLayout>
  20. </FlexboxLayout>
  21. ```
  22.  
  23. login.component.ts
  24. ```ts
  25. import { Component, ElementRef, ViewChild } from "@angular/core";
  26. import { Router } from "@angular/router";
  27. import { alert, prompt } from "tns-core-modules/ui/dialogs";
  28. import { Page } from "tns-core-modules/ui/page";
  29.  
  30. import { User } from "../shared/user.model";
  31. // import { UserService } from "../shared/user.service";
  32.  
  33. @Component({
  34. selector: "app-login",
  35. moduleId: module.id,
  36. templateUrl: "./login.component.html",
  37. styleUrls: ['./login.component.sass']
  38. })
  39. export class LoginComponent {
  40. user: User;
  41. @ViewChild("password") password: ElementRef;
  42.  
  43. constructor(private page: Page, private router: Router) {
  44. this.page.actionBarHidden = true;
  45. this.user = new User();
  46. // this.user.email = "foo2@foo.com";
  47. // this.user.password = "foo";
  48. }
  49.  
  50. submit() {
  51. if (!this.user.email || !this.user.password) {
  52. // this.alert("Please provide both an email address and password.");
  53. console.log(this.user);
  54. this.alert(`EMail: ${this.user.email} Password: ${this.user.password}`);
  55. return;
  56. }
  57.  
  58. this.login();
  59. }
  60.  
  61. login() {
  62. console.log('we are logging in!!')
  63. this.router.navigate(["/home"]);
  64. }
  65.  
  66. focusPassword() {
  67. this.password.nativeElement.focus();
  68. }
  69.  
  70. alert(message: string) {
  71. return alert({
  72. title: "Maxanet Uploader",
  73. okButtonText: "OK",
  74. message: message
  75. });
  76. }
  77. }
  78. ```
Add Comment
Please, Sign In to add comment