Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { HttpClientModule } from '@angular/common/http';
  2. import { HttpClient } from '@angular/common/http'; // nakon toga samo inject u service
  3.  
  4. //rute
  5. const routes: Route[] = [
  6.   { path: '', component: UsersComponent },
  7.   { path: 'users', component: UsersComponent },
  8.   { path: 'adduser', component: AdduserComponent }
  9. ];
  10.  
  11. <a routerLink="/adduser" routerLinkActive="active" class="nav-link" href="javascript:void(0)">Add user</a>
  12. <router-outlet></router-outlet>
  13.  
  14. //TEMPLATE FORM
  15. <form (ngSubmit)="addUser(form)" #form="ngForm" class="col-md-9 offset-md-1">
  16.   <div class="form-group">
  17.     <label for="">Username</label>
  18.     <input ngModel #username="ngModel" type="text" name="username" class="form-control" required>
  19.     <span *ngIf="form.submitted && username.invalid || username.touched" class="helper-text">
  20.       <small class="text-danger">
  21.         Username is not valid
  22.       </small>
  23.     </span>
  24.   </div>
  25.  
  26. //Animations
  27.  
  28. @Component({
  29. animations:[
  30.     trigger('todosAnimation', [
  31.       transition(':enter', [
  32.         group([
  33.           query('h1', [
  34.             style({ transform: 'translateY(-20px)'}),
  35.             animate(1000)
  36.           ]),
  37.           query('@todoAnimation',
  38.               stagger(200, animateChild())
  39.           )
  40.         ])
  41.       ])
  42.     ]),
  43.     trigger('todoAnimation', [
  44.       transition(':enter', [
  45.         useAnimation(fadeInAnimation, {
  46.           params: {
  47.             duration: '500ms'
  48.           }
  49.         })
  50.       ]),
  51.       transition(':leave', [
  52.         style({ backgroundColor: '#ff0000'}),
  53.         animate(1000),
  54.         useAnimation(fadeOutLeftAnimation)
  55.       ])
  56.     ])
  57.   ]
  58. });
  59.  
  60.  
  61. //HTML
  62.  
  63. <div @todosAnimation>
  64.   <h1>Todos</h1>
  65.  
  66.   <input #itemInput
  67.     class="form-control"
  68.     (keyup.enter)="addItem(itemInput)">
  69.  
  70.   <div *ngIf="items" class="list-group" >
  71.     <button type="button"
  72.       @todoAnimation
  73.       (@todoAnimation.start)="animationStarted($event)"
  74.       (@todoAnimation.done)="animationDone($event)"
  75.       *ngFor="let item of items"
  76.       (click)="removeItem(item)"
  77.       class="list-group-item"
  78.       >{{ item }}</button>
  79.   </div>
  80. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement