Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.84 KB | None | 0 0
  1. <div class="row">
  2. <div class="col-xs-12 col-sm-4">
  3. <div class="list-group">
  4. <a
  5. [routerLink] = "['/servers', 5, 'edit']"
  6. [queryParams] = "{allowEdit: '1'}" <!-- Query parameter ? -->
  7. fragment = "loading" <!-- URL fragment #loading -->
  8. href="#"
  9. class="list-group-item"
  10. *ngFor="let server of servers">
  11. {{ server.name }}
  12. </a>
  13. </div>
  14. </div>
  15. <div class="col-xs-12 col-sm-4">
  16. <button class="btn btn-primary" (click)="onReload()">Reload Page Navigating Programatically</button>
  17. <a routerLink="/servers">Reload Page</a>
  18. <!--<app-edit-server></app-edit-server>-->
  19. <hr>
  20. <app-server></app-server>
  21. </div>
  22. </div>
  23.  
  24. import { Component, OnInit } from '@angular/core';
  25. import { ServersService } from './servers.service';
  26. import {ActivatedRoute, Router} from '@angular/router';
  27.  
  28. @Component({
  29. selector: 'app-servers',
  30. templateUrl: './servers.component.html',
  31. styleUrls: ['./servers.component.css']
  32. })
  33. export class ServersComponent implements OnInit {
  34. private servers: {id: number, name: string, status: string}[] = [];
  35.  
  36. constructor(private serversService: ServersService,
  37. private router: Router,
  38. private route: ActivatedRoute) { }
  39.  
  40. ngOnInit() {
  41. this.servers = this.serversService.getServers();
  42. }
  43.  
  44. /**
  45. * relativeTo specify the relative route and can be used to use relative path as '/servers' when the
  46. * programatica navigation is used
  47. */
  48. onReload() {
  49. this.router.navigate(['/servers'], {relativeTo: this.route});
  50. }
  51.  
  52. }
  53.  
  54. <h5>{{ server.name }}</h5>
  55. <p>Server status is {{ server.status }}</p>
  56.  
  57. import { Component, OnInit } from '@angular/core';
  58. import { ServersService } from '../servers.service';
  59.  
  60. @Component({
  61. selector: 'app-server',
  62. templateUrl: './server.component.html',
  63. styleUrls: ['./server.component.css']
  64. })
  65. export class ServerComponent implements OnInit {
  66. server: {id: number, name: string, status: string};
  67.  
  68. constructor(private serversService: ServersService) { }
  69.  
  70. ngOnInit() {
  71. this.server = this.serversService.getServer(1); // retrieve the specific server related to this ID
  72. }
  73.  
  74. }
  75.  
  76. import { BrowserModule } from '@angular/platform-browser';
  77. import { NgModule } from '@angular/core';
  78. import { FormsModule } from '@angular/forms';
  79. import { HttpModule } from '@angular/http';
  80.  
  81. import { AppComponent } from './app.component';
  82. import { HomeComponent } from './home/home.component';
  83. import { UsersComponent } from './users/users.component';
  84. import { ServersComponent } from './servers/servers.component';
  85. import { UserComponent } from './users/user/user.component';
  86. import { EditServerComponent } from './servers/edit-server/edit-server.component';
  87. import { ServerComponent } from './servers/server/server.component';
  88. import { ServersService } from './servers/servers.service';
  89. import {RouterModule, Routes} from '@angular/router';
  90.  
  91. /**
  92. * It specify a path and the component that have to be showed as a page for this path (but still a single page application).
  93. * The view of the component is replaced in the DOM of outr single page by Angular
  94. * @type {[{path: string; component: UserComponent}]}
  95. */
  96. const appRoutes: Routes = [
  97. { path: '', component: HomeComponent },
  98. { path: 'users', component: UsersComponent },
  99. { path: 'users/:id/:name', component: UserComponent}, /* Single parametrized (:id) user */
  100. { path: 'servers', component: ServersComponent },
  101. { path: 'servers/:id/edit', component: EditServerComponent }
  102. ]
  103.  
  104. @NgModule({
  105. declarations: [
  106. AppComponent,
  107. HomeComponent,
  108. UsersComponent,
  109. ServersComponent,
  110. UserComponent,
  111. EditServerComponent,
  112. ServerComponent
  113. ],
  114. imports: [
  115. BrowserModule,
  116. FormsModule,
  117. HttpModule,
  118. RouterModule.forRoot(appRoutes) // Register our routes in our application
  119. ],
  120. providers: [ServersService],
  121. bootstrap: [AppComponent]
  122. })
  123. export class AppModule { }
  124.  
  125. Angular is running in the development mode. Call enableProdMode() to enable the production mode.
  126. core.es5.js:1020 ERROR Error: Uncaught (in promise): InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': '--' is not a valid attribute name.
  127. Error: Failed to execute 'setAttribute' on 'Element': '--' is not a valid attribute name.
  128. at EmulatedEncapsulationDomRenderer2.DefaultDomRenderer2.setAttribute (platform-browser.es5.js:2825)
  129. at DebugRenderer2.setAttribute (core.es5.js:13653)
  130. at createElement (core.es5.js:9177)
  131. at createViewNodes (core.es5.js:12146)
  132. at callViewAction (core.es5.js:12626)
  133. at execComponentViewsAction (core.es5.js:12535)
  134. at createViewNodes (core.es5.js:12207)
  135. at createRootView (core.es5.js:12075)
  136. at callWithDebugContext (core.es5.js:13458)
  137. at Object.debugCreateRootView [as createRootView] (core.es5.js:12775)
  138. at EmulatedEncapsulationDomRenderer2.DefaultDomRenderer2.setAttribute (platform-browser.es5.js:2825)
  139. at DebugRenderer2.setAttribute (core.es5.js:13653)
  140. at createElement (core.es5.js:9177)
  141. at createViewNodes (core.es5.js:12146)
  142. at callViewAction (core.es5.js:12626)
  143. at execComponentViewsAction (core.es5.js:12535)
  144. at createViewNodes (core.es5.js:12207)
  145. at createRootView (core.es5.js:12075)
  146. at callWithDebugContext (core.es5.js:13458)
  147. at Object.debugCreateRootView [as createRootView] (core.es5.js:12775)
  148. at resolvePromise (zone.js:783)
  149. at resolvePromise (zone.js:754)
  150. at zone.js:831
  151. at ZoneDelegate.invokeTask (zone.js:424)
  152. at Object.onInvokeTask (core.es5.js:3881)
  153. at ZoneDelegate.invokeTask (zone.js:423)
  154. at Zone.runTask (zone.js:191)
  155. at drainMicroTaskQueue (zone.js:595)
  156. at <anonymous>
  157. defaultErrorLogger @ core.es5.js:1020
  158. ErrorHandler.handleError @ core.es5.js:1080
  159. next @ core.es5.js:4503
  160. schedulerFn @ core.es5.js:3635
  161. SafeSubscriber.__tryOrUnsub @ Subscriber.js:238
  162. SafeSubscriber.next @ Subscriber.js:185
  163. Subscriber._next @ Subscriber.js:125
  164. Subscriber.next @ Subscriber.js:89
  165. Subject.next @ Subject.js:55
  166. EventEmitter.emit @ core.es5.js:3621
  167. (anonymous) @ core.es5.js:3912
  168. ZoneDelegate.invoke @ zone.js:391
  169. Zone.run @ zone.js:141
  170. NgZone.runOutsideAngular @ core.es5.js:3844
  171. onHandleError @ core.es5.js:3912
  172. ZoneDelegate.handleError @ zone.js:395
  173. Zone.runGuarded @ zone.js:157
  174. _loop_1 @ zone.js:666
  175. api.microtaskDrainDone @ zone.js:675
  176. drainMicroTaskQueue @ zone.js:603
  177. Promise resolved (async)
  178. scheduleMicroTask @ zone.js:578
  179. ZoneDelegate.scheduleTask @ zone.js:413
  180. Zone.scheduleTask @ zone.js:235
  181. Zone.scheduleMicroTask @ zone.js:255
  182. scheduleResolveOrReject @ zone.js:829
  183. ZoneAwarePromise.then @ zone.js:918
  184. PlatformRef_._bootstrapModuleWithZone @ core.es5.js:4537
  185. PlatformRef_.bootstrapModule @ core.es5.js:4522
  186. 122 @ main.ts:11
  187. __webpack_require__ @ bootstrap 7f61d62415a6f5810bca:52
  188. 290 @ main.bundle.js:663
  189. __webpack_require__ @ bootstrap 7f61d62415a6f5810bca:52
  190. webpackJsonpCallback @ bootstrap 7f61d62415a6f5810bca:23
  191. (anonymous) @ main.bundle.js:1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement