Skip to content

Instantly share code, notes, and snippets.

View brunokrebs's full-sized avatar

Bruno brunokrebs

  • Brazil
View GitHub Profile
@import '~ng2-slim-loading-bar/bundles/style.css';
/* ... everything else ... */
// ... other module imports
import { SlimLoadingBarModule } from 'ng2-slim-loading-bar';
@NgModule({
// ... declarations
imports: [
// ... other imports
SlimLoadingBarModule.forRoot()
],
// ... providers and bootstrap
<md-card>
<!-- ... card title and subtitle -->
<app-task-form (taskAdded)="taskAddedHandler($event)"></app-task-form>
<!-- ... md-list -->
</md-card>
<div class="task-form">
<md-input-container>
<input mdInput [(ngModel)]="task" placeholder="New task">
</md-input-container>
<button md-button md-raised-button color="primary" (click)="addTask()">Add</button>
</div>
import { Component, EventEmitter, Output } from '@angular/core';
@Component({
selector: 'app-task-form',
templateUrl: './task-form.component.html',
styleUrls: ['./task-form.component.css']
})
export class TaskFormComponent {
@Output()
<app-nav-bar></app-nav-bar>
<div class="app-container">
<!-- ... card with welcome message -->
<app-task-list *ngIf="authService.authenticated()"></app-task-list>
</div>
.task-item {
padding: 10px;
margin-bottom: 10px;
background-color: #eee;
}
button.delete {
float: right;
top: -60px;
}
<md-card>
<md-card-title>Task List</md-card-title>
<md-card-subtitle>All your tasks in one place.</md-card-subtitle>
<md-list>
<div class="task-item" *ngFor="let task of tasks; trackBy: $index">
<p><small><strong>{{ task.createdAt | date: 'short' }}</strong></small></p>
<p>{{ task.description }}</p>
<button class="delete" md-button md-raised-button
color="accent" (click)="deleteTask(task)">Delete</button>
</div>
import { Component, OnInit } from '@angular/core';
import { TaskListService } from './task-list.service';
@Component({
selector: 'app-task-list',
templateUrl: './task-list.component.html',
styleUrls: [ './task-list.component.css' ]
})
export class TaskListComponent implements OnInit {
// ... other imports
import { Http, RequestOptions } from '@angular/http';
import { AuthHttp, AuthConfig } from 'angular2-jwt';
import { TaskListService } from './task-list/task-list.service';
// creates a factory to AuthHttp
export function authHttpFactory(http: Http, options: RequestOptions) {
return new AuthHttp(new AuthConfig(), http, options);
}