在visual studio 2015

时间:2017-06-09 09:56:47

标签: asp.net-mvc angular angular-cli

我正在尝试将angular-cli生成的Angular 4与MVC 5集成。我需要通过MVC视图加载角度。有人可以告诉我如何去做。大多数示例显示在布局文件中引用systemjs.js。 Angular cli不会生成该文件,而是使用.angular-cli.json文件。我还需要加载index.cshtml而不是index.html

enter image description here

.angular-cli.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "MRDB.Web"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

的index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Angular4app</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>

启动

using Microsoft.Owin;
using Owin;

[assembly: OwinStartupAttribute(typeof(MRDB.Startup))]
namespace MRDB
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我不确定你是怎么做到的?根据我的理解,Angular是一个完整的前端框架,您可以简单地将所有文件放到站点而不是MVC项目。