Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. @{
  2. Layout = null;
  3. ViewBag.Title = "Home Page";
  4. }
  5.  
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <base href="@Url.Content("~/")">
  10. <title>MVC 4 Angular 4</title>
  11. <meta charset="utf-8" />
  12. <meta name="viewport" content="width=device-width, initial-scale=1">
  13.  
  14. <script src="dist/scripts/packages/core-js/client/shim.min.js"></script>
  15. <script src="dist/scripts/packages/zone.js/dist/zone.js"></script>
  16. <script src="dist/scripts/packages/systemjs/dist/system.src.js"></script>
  17. <script src="systemjs.config.js"></script>
  18. <script>
  19. System.import('dist/scripts/main.js').catch(function (err) {
  20. console.error(err);
  21. });
  22. </script>
  23. </head>
  24. <body>
  25. <my-app>Loading...</my-app>
  26. </body>
  27. </html>
  28.  
  29. import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
  30. import { AppModule } from './app.module';
  31.  
  32. platformBrowserDynamic().bootstrapModule(AppModule);
  33.  
  34. import { NgModule } from "@angular/core";
  35. import { BrowserModule } from "@angular/platform-browser";
  36. import { FormsModule } from '@angular/forms';
  37. import { RouterModule } from '@angular/router';
  38. import { LocationStrategy, HashLocationStrategy } from '@angular/common';
  39.  
  40. import { AppComponent } from "./Components/app";
  41. import { Page1 } from "./Components/page1";
  42. import { Page2 } from "./Components/page2";
  43.  
  44. @NgModule({
  45. imports: [
  46. BrowserModule,
  47. FormsModule,
  48. RouterModule.forRoot([
  49. {
  50. path: 'page1',
  51. component: Page1
  52. },
  53. {
  54. path: 'page2',
  55. component: Page2
  56. },
  57. {
  58. path: '',
  59. redirectTo: '/page1',
  60. pathMatch: 'full'
  61. }
  62. ])
  63. // other imports here
  64. ],
  65. exports: [RouterModule],
  66. declarations: [
  67. AppComponent,
  68. Page1,
  69. Page2
  70. ],
  71. providers: [],
  72. bootstrap: [AppComponent]
  73. })
  74. export class AppModule { }
  75.  
  76. import { Component } from "@angular/core";
  77.  
  78. @Component({
  79. selector: "my-app",
  80. template: `
  81. <h1>{{app}}</h1>
  82. <nav id="main-menu">
  83. <a class="menu-item" routerLink="/page1" routerLinkActive="active">Page1</a>
  84. <a class="menu-item" routerLink="/page2" routerLinkActive="active">Page2</a>
  85. </nav>
  86. <router-outlet></router-outlet>
  87. `
  88. })
  89. export class AppComponent {
  90. app= "App"
  91. }
  92.  
  93. import { Component } from '@angular/core';
  94.  
  95. @Component({
  96. selector: 'page1',
  97. template: "<div>page1</div>",
  98. styleUrls: []
  99. })
  100. export class Page1 { }
  101.  
  102. <system.webServer>
  103. <rewrite>
  104. <rules>
  105. <rule name="Angular Routes" stopProcessing="true">
  106. <match url=".*" />
  107. <conditions logicalGrouping="MatchAll">
  108. <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
  109. <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
  110. </conditions>
  111. <action type="Rewrite" url="/src/" />
  112. </rule>
  113. </rules>
  114. </rewrite>
  115. </system.webServer>
  116.  
  117. import { Component } from '@angular/core';
  118.  
  119. @Component({
  120. selector: 'page1',
  121. templateUrl: "home/about",
  122. styleUrls: []
  123. })
  124. export class Page1 { }
  125.  
  126. public ActionResult About()
  127. {
  128. ViewBag.Message = "Your application description page.";
  129. return View();
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement