Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @{
- Layout = null;
- ViewBag.Title = "Home Page";
- }
- <!DOCTYPE html>
- <html>
- <head>
- <base href="@Url.Content("~/")">
- <title>MVC 4 Angular 4</title>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <script src="dist/scripts/packages/core-js/client/shim.min.js"></script>
- <script src="dist/scripts/packages/zone.js/dist/zone.js"></script>
- <script src="dist/scripts/packages/systemjs/dist/system.src.js"></script>
- <script src="systemjs.config.js"></script>
- <script>
- System.import('dist/scripts/main.js').catch(function (err) {
- console.error(err);
- });
- </script>
- </head>
- <body>
- <my-app>Loading...</my-app>
- </body>
- </html>
- import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
- import { AppModule } from './app.module';
- platformBrowserDynamic().bootstrapModule(AppModule);
- import { NgModule } from "@angular/core";
- import { BrowserModule } from "@angular/platform-browser";
- import { FormsModule } from '@angular/forms';
- import { RouterModule } from '@angular/router';
- import { LocationStrategy, HashLocationStrategy } from '@angular/common';
- import { AppComponent } from "./Components/app";
- import { Page1 } from "./Components/page1";
- import { Page2 } from "./Components/page2";
- @NgModule({
- imports: [
- BrowserModule,
- FormsModule,
- RouterModule.forRoot([
- {
- path: 'page1',
- component: Page1
- },
- {
- path: 'page2',
- component: Page2
- },
- {
- path: '',
- redirectTo: '/page1',
- pathMatch: 'full'
- }
- ])
- // other imports here
- ],
- exports: [RouterModule],
- declarations: [
- AppComponent,
- Page1,
- Page2
- ],
- providers: [],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
- import { Component } from "@angular/core";
- @Component({
- selector: "my-app",
- template: `
- <h1>{{app}}</h1>
- <nav id="main-menu">
- <a class="menu-item" routerLink="/page1" routerLinkActive="active">Page1</a>
- <a class="menu-item" routerLink="/page2" routerLinkActive="active">Page2</a>
- </nav>
- <router-outlet></router-outlet>
- `
- })
- export class AppComponent {
- app= "App"
- }
- import { Component } from '@angular/core';
- @Component({
- selector: 'page1',
- template: "<div>page1</div>",
- styleUrls: []
- })
- export class Page1 { }
- <system.webServer>
- <rewrite>
- <rules>
- <rule name="Angular Routes" stopProcessing="true">
- <match url=".*" />
- <conditions logicalGrouping="MatchAll">
- <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
- <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
- </conditions>
- <action type="Rewrite" url="/src/" />
- </rule>
- </rules>
- </rewrite>
- </system.webServer>
- import { Component } from '@angular/core';
- @Component({
- selector: 'page1',
- templateUrl: "home/about",
- styleUrls: []
- })
- export class Page1 { }
- public ActionResult About()
- {
- ViewBag.Message = "Your application description page.";
- return View();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement