Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- login.component.html
- ```html
- <FlexboxLayout class="page">
- <StackLayout class="form">
- <Image class="logo" src="~/images/icon.png"></Image>
- <Label class="header" text="Maxanet Uploader"></Label>
- <StackLayout class="input-field">
- <TextField class="input" hint="Email" keyboardType="email" autocorrect="false" autocapitalizationType="none" [(ngModel)]="user.email" returnKeyType="next" (returnPress)="focusPassword()"></TextField>
- <StackLayout class="hr-light"></StackLayout>
- </StackLayout>
- <StackLayout class="input-field">
- <TextField #password class="input" hint="Password" secure="true" [(ngModel)]="user.password" [returnKeyType]="'done'" (returnPress)="submit()"></TextField>
- <StackLayout class="hr-light"></StackLayout>
- </StackLayout>
- <Button [text]="'Log In'" (tap)="submit()" class="btn btn-primary m-t-20"></Button>
- </StackLayout>
- </FlexboxLayout>
- ```
- login.component.ts
- ```ts
- import { Component, ElementRef, ViewChild } from "@angular/core";
- import { Router } from "@angular/router";
- import { alert, prompt } from "tns-core-modules/ui/dialogs";
- import { Page } from "tns-core-modules/ui/page";
- import { User } from "../shared/user.model";
- // import { UserService } from "../shared/user.service";
- @Component({
- selector: "app-login",
- moduleId: module.id,
- templateUrl: "./login.component.html",
- styleUrls: ['./login.component.sass']
- })
- export class LoginComponent {
- user: User;
- @ViewChild("password") password: ElementRef;
- constructor(private page: Page, private router: Router) {
- this.page.actionBarHidden = true;
- this.user = new User();
- // this.user.email = "foo2@foo.com";
- // this.user.password = "foo";
- }
- submit() {
- if (!this.user.email || !this.user.password) {
- // this.alert("Please provide both an email address and password.");
- console.log(this.user);
- this.alert(`EMail: ${this.user.email} Password: ${this.user.password}`);
- return;
- }
- this.login();
- }
- login() {
- console.log('we are logging in!!')
- this.router.navigate(["/home"]);
- }
- focusPassword() {
- this.password.nativeElement.focus();
- }
- alert(message: string) {
- return alert({
- title: "Maxanet Uploader",
- okButtonText: "OK",
- message: message
- });
- }
- }
- ```
Add Comment
Please, Sign In to add comment