Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { NgModule, ModuleWithProviders } from '@angular/core';
- import { CommonModule } from '@angular/common';
- /* Nativescript modules */
- import { NativeScriptFormsModule } from 'nativescript-angular/forms';
- import { NativeScriptModule } from 'nativescript-angular/nativescript.module';
- import { NativeScriptRouterModule } from 'nativescript-angular/router';
- import { registerElement } from 'nativescript-angular/element-registry';
- registerElement('CardView', () => require('nativescript-cardview').CardView);
- /* End nativescript modules */
- import { StoreModule } from '@ngrx/store';
- import { EffectsModule } from '@ngrx/effects';
- import { LoginPageComponent } from './containers/login-page/login-page.component';
- import { RegisterPageComponent } from './containers/register-page/register-page.component';
- import { ForgotPasswordPageComponent } from './containers/forgot-password-page/forgot-password-page.component';
- import { LoginFormComponent } from './components/login-form/login-form.component';
- import { RegisterFormComponent } from './components/register-form/register-form.component';
- import { ForgotPasswordFormComponent } from './components/forgot-password-form/forgot-password-form.component';
- import { TermsComponent } from './components/terms/terms.component';
- import { AuthService } from './services/auth.service';
- import { AuthGuard, LazyAuthGuard } from './services/auth-guard.service';
- import { AuthEffects } from './effects/auth.effects';
- import { reducers } from './reducers';
- import { AuthRoutingModule } from './auth-routing.module';
- export const COMPONENTS = [
- LoginPageComponent,
- RegisterPageComponent,
- ForgotPasswordPageComponent,
- LoginFormComponent,
- RegisterFormComponent,
- ForgotPasswordFormComponent,
- TermsComponent,
- ];
- @NgModule({
- imports: [
- CommonModule,
- NativeScriptModule,
- NativeScriptRouterModule,
- NativeScriptFormsModule,
- ],
- declarations: COMPONENTS,
- exports: COMPONENTS,
- entryComponents: [TermsComponent],
- })
- export class AuthModule {
- static forRoot(): ModuleWithProviders {
- return {
- ngModule: RootAuthModule,
- providers: [AuthService, AuthGuard, LazyAuthGuard],
- };
- }
- }
- @NgModule({
- imports: [
- AuthModule,
- AuthRoutingModule,
- StoreModule.forFeature('auth', reducers),
- EffectsModule.forFeature([AuthEffects]),
- ],
- })
- export class RootAuthModule {}
- import { Component } from '@angular/core';
- import { ModalDialogParams } from 'nativescript-angular/modal-dialog';
- import { Page } from 'ui/page';
- import { terms, Terms } from './terms';
- @Component({
- moduleId: module.id,
- selector: 'terms-dialog',
- templateUrl: 'terms.component.html',
- })
- export class TermsComponent {
- public currentdate: Date;
- public test = 'sdfsdfsdfsd';
- public terms: Terms = terms;
- constructor(private params: ModalDialogParams, private page: Page) {
- this.page.on('unloaded', () => {
- // using the unloaded event to close the modal when there is user interaction
- // e.g. user taps outside the modal page
- this.params.closeCallback();
- });
- this.currentdate = new Date();
- }
- public getText(){
- return 'some text';
- }
- public close() {
- debugger;
- this.params.closeCallback();
- }
- }
- import {
- Component,
- OnInit,
- Input,
- Output,
- EventEmitter,
- ViewContainerRef,
- } from '@angular/core';
- import { FormGroup, FormControl } from '@angular/forms';
- import { Register } from '../../models/user';
- import { Config } from '../../../common/index';
- import { TermsComponent } from '../terms/terms.component';
- /* Mobile Specific Stuff */
- import imagepicker = require('nativescript-imagepicker');
- import {
- ModalDialogService,
- ModalDialogOptions,
- } from 'nativescript-angular/modal-dialog';
- @Component({
- moduleId: module.id,
- selector: 'bc-register-form',
- templateUrl: 'register-form.component.html',
- styleUrls: ['register-form.component.scss'],
- })
- export class RegisterFormComponent implements OnInit {
- @Input()
- set pending(isPending: boolean) {
- if (isPending) {
- this.form.disable();
- } else {
- this.form.enable();
- }
- }
- @Input() errorMessage: string | null;
- @Output() submitted = new EventEmitter<Register>();
- form: FormGroup = new FormGroup({
- username: new FormControl(''),
- password: new FormControl(''),
- email: new FormControl(''),
- avatar: new FormControl(''),
- });
- avatarFilePreview: any;
- constructor(
- public modalService: ModalDialogService,
- private viewContainer: ViewContainerRef
- ) {}
- ngOnInit() {
- this.form.get('avatar').valueChanges.subscribe(v => {
- this.avatarFilePreview = v._files[0];
- });
- }
- openDialog() {
- const options: ModalDialogOptions = {
- fullscreen: false,
- viewContainerRef: this.viewContainer,
- context: {}
- };
- return this.modalService.showModal(TermsComponent, options);
- }
- getNativescriptImagePicker() {
- let context = imagepicker.create({
- mode: 'single',
- });
- var self = this;
- context
- .authorize()
- .then(function() {
- return context.present();
- })
- .then(function(selection) {
- self.avatarFilePreview = selection[0];
- })
- .catch(function(e) {
- // process error
- });
- }
- submit() {
- if (this.form.valid) {
- this.submitted.emit(this.form.value);
- }
- }
- }
Add Comment
Please, Sign In to add comment