|
1 | 1 | # todo-angular2
|
2 | 2 | A TODO list app created in Angular 2
|
| 3 | + |
| 4 | +################################################ |
| 5 | +# STEP 1 : Set up the Development Environment |
| 6 | +################################################ |
| 7 | + |
| 8 | +Install Node.js® and npm if they are not already on your machine |
| 9 | + |
| 10 | +Visit : https://nodejs.org/en/download/ |
| 11 | + |
| 12 | +################################################ |
| 13 | +# STEP 2 : Install Angular CLI |
| 14 | +################################################ |
| 15 | + |
| 16 | + npm install -g @angular/cli |
| 17 | + |
| 18 | +################################################ |
| 19 | +# STEP 3 : Create a new Project |
| 20 | +################################################ |
| 21 | + |
| 22 | + ng new my-application |
| 23 | + |
| 24 | +################################################ |
| 25 | +# STEP 4 : Serve the application |
| 26 | +################################################ |
| 27 | + |
| 28 | + cd my-app |
| 29 | + ng serve --open [ or ng serve -o ] |
| 30 | + |
| 31 | +############################################### |
| 32 | +# To Generate Service Form CLI |
| 33 | +############################################### |
| 34 | + |
| 35 | + ng g service restservice |
| 36 | + |
| 37 | +################################################ |
| 38 | +# BOOTSTRAP INTEGRATION |
| 39 | +################################################ |
| 40 | + |
| 41 | +# 1) Open below link |
| 42 | + |
| 43 | + Visit : https://ng-bootstrap.github.io/#/home |
| 44 | + |
| 45 | +# 2) Click on Installation button |
| 46 | + |
| 47 | +# 3) Installation |
| 48 | + |
| 49 | + npm install --save @ng-bootstrap/ng-bootstrap |
| 50 | + |
| 51 | +# 4) Once installed you need to import our main module |
| 52 | + |
| 53 | + import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; |
| 54 | + |
| 55 | +# 5) Need to add imports in AppModule |
| 56 | + |
| 57 | + Example : |
| 58 | + |
| 59 | + @NgModule({ |
| 60 | + declarations: [AppComponent, ...], |
| 61 | + imports: [NgbModule.forRoot(), ...], // forRoot is used to add application/singleton services. |
| 62 | + bootstrap: [AppComponent] |
| 63 | + }) |
| 64 | + |
| 65 | + export class AppModule { |
| 66 | + } |
| 67 | + |
| 68 | +# 6) Install bootstrap (Using only for CSS reference) |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +# 7) Add css link to .angular-cli.json file |
| 73 | + |
| 74 | + Example : |
| 75 | + |
| 76 | + "styles": [ |
| 77 | + "styles.css", |
| 78 | + "../node_modules/bootstrap/dist/css/bootstrap.css" |
| 79 | + ] |
| 80 | + |
| 81 | + |
| 82 | +####################################################### |
| 83 | +# TODO COMPONENT TEMPLATE |
| 84 | +####################################################### |
| 85 | + |
| 86 | +<div class="container"> |
| 87 | + <div class="col-xs-2"> |
| 88 | + <ul class="list-group"> |
| 89 | + <li class="list-group-item"> |
| 90 | + </li> |
| 91 | + </ul> |
| 92 | + </div> |
| 93 | +</div> |
| 94 | + |
| 95 | +######################################################## |
| 96 | +# TASK COMPONENT TEMPLATE |
| 97 | +######################################################## |
| 98 | + |
| 99 | +<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> |
| 100 | +<div class="container"> |
| 101 | + <div class="row"> |
| 102 | + <div class="col-sm-1"> |
| 103 | + <!-- Checkbox --> |
| 104 | + </div> |
| 105 | + <div class="col-sm-9"> |
| 106 | + <!-- Form --> |
| 107 | + </div> |
| 108 | + <div class="col-sm-1"> |
| 109 | + <!-- delete button --> |
| 110 | + <span class="fa fa-trash-o" style="cursor:pointer;"></span> |
| 111 | + </div> |
| 112 | + </div> |
| 113 | +</div> |
| 114 | + |
| 115 | +####################################################### |
| 116 | +# FORM Validation css |
| 117 | +####################################################### |
| 118 | + |
| 119 | +<div class="form-group" [ngClass]="form.get('updatedTask').hasError('required') && isSubmitted ? 'has-danger' : ''"> |
| 120 | + <input type="text" class="form-control input-sm form-control-danger" id="task" placeholder="Add a task" formControlName="updatedTask" focus/> |
| 121 | + <div class="form-control-feedback" \*ngIf="form.get('updatedTask').hasError('required') && isSubmitted"> |
| 122 | + Task name is required |
| 123 | + </div> |
| 124 | +</div> |
| 125 | + |
| 126 | +######################################################## |
| 127 | +# STRIKETHROUGH CSS |
| 128 | +######################################################## |
| 129 | + |
| 130 | +<span [ngClass]="task.isDone ? 'task-done' : 'task'" (click)="enableEditing()" \*ngIf="!editable" style="cursor:pointer;" > |
| 131 | +</span> |
| 132 | + |
| 133 | +####################################################### |
| 134 | +# How to make DRAG & DROP TODO |
| 135 | +####################################################### |
| 136 | + |
| 137 | + 1) Install DndModule |
| 138 | + |
| 139 | + npm install ng2-dnd --save |
| 140 | + |
| 141 | + 2) Update App.module.ts |
| 142 | + |
| 143 | + import {BrowserModule} from "@angular/platform-browser"; |
| 144 | + import {NgModule} from '@angular/core'; |
| 145 | + import {DndModule} from 'ng2-dnd'; |
| 146 | + |
| 147 | + @NgModule({ |
| 148 | + imports: [ |
| 149 | + BrowserModule, |
| 150 | + DndModule.forRoot() |
| 151 | + ], |
| 152 | + bootstrap: [AppComponent] |
| 153 | + }) |
| 154 | + export class AppModule { |
| 155 | + } |
| 156 | + |
| 157 | +######################################################## |
| 158 | +# Angular 2 Bootstrap + Bootstrap Styling |
| 159 | +######################################################## |
| 160 | + |
| 161 | +Using bootstrap components in Angular 2 Visit: https://valor-software.com/ng2-bootstrap/#/ |
| 162 | + |
| 163 | + |
| 164 | +######################################################## |
| 165 | +# |
| 166 | +######################################################## |
0 commit comments