Skip to content

Instantly share code, notes, and snippets.

View azaharafernandezguizan's full-sized avatar

Azahara Fernández Guizán azaharafernandezguizan

View GitHub Profile
@azaharafernandezguizan
azaharafernandezguizan / app.route.module.ts
Created November 3, 2018 15:45
Example of Angular app.route.module.ts with multi modules
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{
path: 'login',
loadChildren: './pages/login/login.module#LoginModule'
},
@azaharafernandezguizan
azaharafernandezguizan / shared.module.ts
Created November 3, 2018 15:50
Example of Angular´s shared module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ApiService } from './_services/api.service';
import { CommonsService } from './_services/commons.service';
import { ErrorsService} from './_services/errors.service';
import { RoomService } from './_services/room.service';
@NgModule({
imports: [
@azaharafernandezguizan
azaharafernandezguizan / room.service.ts
Created November 3, 2018 15:53
Example of angular Service with dependency injection problem.
import { Injectable } from '@angular/core';
import { HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { ApiService } from './api.service';
import { RoomDataModel, RoomDetail } from '../_models/rooms.model';
@Injectable()
export class RoomService {
@azaharafernandezguizan
azaharafernandezguizan / magical.lessons.component.ts
Created November 3, 2018 16:02
Example of angular component using resolver.ts
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { CommonsService } from '../../_services/commons.service';
import { ErrorsService } from '../../_services/errors.service';
import { RoomService } from 'src/app/_services/room.service';
import { RoomDetail } from 'src/app/_models/rooms.model';
@Component({
selector: 'app-magical-lessons',
@azaharafernandezguizan
azaharafernandezguizan / magical.lessons.list.component.ts
Created November 3, 2018 16:06
Example of angular component instantiating a service.
import { Component, OnInit } from '@angular/core';
import { CommonsService } from '../../_services/commons.service';
import { ErrorsService } from '../../_services/errors.service';
import { RoomService } from 'src/app/_services/room.service';
import { RoomDataModel } from 'src/app/_models/rooms.model';
@Component({
selector: 'app-magicalLessons-list',
templateUrl: './magical.lessons.list.component.html',
styleUrls: ['./magical.lessons.list.component.css']
@azaharafernandezguizan
azaharafernandezguizan / app.route.module.ts
Created November 3, 2018 16:32
Angular app route module when components declared inside app.module
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './pages/home/home.component';
import { MagicalLessonsListComponent } from './pages/magicalLessons/magical.lessons.list.component';
import { MagicalLessonsComponent } from './pages/magicalLessons/magical.lessons.component';
const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'lessons', component: MagicalLessonsListComponent },
@azaharafernandezguizan
azaharafernandezguizan / app.module.ts
Last active November 3, 2018 16:37
Angular app.module.ts example
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing-module';
import { HomeComponent } from './pages/home/home.component';
import { AuthComponent } from './components/auth/auth.component';
import { ConfirmationComponent } from './components/confirmation/confirmation.component';
import { FooterComponent } from './components/footer/footer.component';
import { HeaderComponent } from './components/header/header.component';
import { CommonModule } from '@angular/common';
import { HttpClientModule, HttpClient } from '@angular/common/http';
@azaharafernandezguizan
azaharafernandezguizan / dragulaExample.html
Created November 12, 2018 09:40
Table formation with dragula not working fine
<div class="dragulaTableNotWorkingFine">
<ul class="tableHeader">
<li class="hiddenCell">
{{'beast.id' | translate}}
</li>
<li>
{{'beast.name' | translate}}
</li>
<li>
{{'beast.description' |translate}}
@azaharafernandezguizan
azaharafernandezguizan / dragulaExample.html
Created November 12, 2018 09:49
Dragula Table working fine
<div class="dragulaTableWorkingFine">
<ul>
<li class="tableHeader">
<div class="hiddenCell">
{{'beast.id' | translate}}
</li>
<li>
{{'beast.name' | translate}}
</li>
<li>
@azaharafernandezguizan
azaharafernandezguizan / dragulaExample.ts
Last active November 12, 2018 10:11
Dragula onDrop funcionality
onDrop(args): void {
this.dragulaService.find('fantasticBeastsTable').drake.cancel(true);
const [labelDragula, el, target, source, sibling] = args;
let movedItemId = Number(el.children[1].innerText.trim());
let movedItem = this.fantasticBeastsList.filter(x=>x.id== movedItemId)[0];
let belowItemId= Number(sibling.children[1].innerText.trim());
let belowItem = this.fantasticBeastsList.filter(x=>x.id== belowItemId)[0];