ASP.NET MVC应用程序中的角区错误

时间:2017-10-08 00:45:56

标签: asp.net-mvc angular configuration install

我试图将角度和MVC应用程序合并在一起。我只是按照一个关于复数的课程的指示,尝试在一个空白的MVC应用程序上进行初始化。但是,当我尝试使用我的app标签来测试功能时,我在控制台中收到以下错误。

  

定价:56错误:(SystemJS)XHR错误(404 Not Found)加载   http://localhost:5794/src/app/app.module错误:XHR错误(404不是   找到)loading http://localhost:5794/src/app/app.module         在XMLHttpRequest.wrapFn(http://localhost:5794/node_modules/zone.js/dist/zone.js:1166:39)         在ZoneDelegate.invokeTask(http://localhost:5794/node_modules/zone.js/dist/zone.js:425:31)         在Zone.runTask(http://localhost:5794/node_modules/zone.js/dist/zone.js:192:47)         在ZoneTask.invokeTask [作为调用](http://localhost:5794/node_modules/zone.js/dist/zone.js:499:34)         at invokeTask(http://localhost:5794/node_modules/zone.js/dist/zone.js:1540:14)         在XMLHttpRequest.globalZoneAwareCallback(http://localhost:5794/node_modules/zone.js/dist/zone.js:1566:17)     加载http://localhost:57594/src/app/app.module时出错   " ./应用程序/ app.module"来自http://localhost:57594/src/main.js         在XMLHttpRequest.wrapFn(http://localhost:5794/node_modules/zone.js/dist/zone.js:1166:39)         在ZoneDelegate.invokeTask(http://localhost:5794/node_modules/zone.js/dist/zone.js:425:31)         在Zone.runTask(http://localhost:5794/node_modules/zone.js/dist/zone.js:192:47)         在ZoneTask.invokeTask [作为调用](http://localhost:5794/node_modules/zone.js/dist/zone.js:499:34)         at invokeTask(http://localhost:5794/node_modules/zone.js/dist/zone.js:1540:14)         在XMLHttpRequest.globalZoneAwareCallback(http://localhost:5794/node_modules/zone.js/dist/zone.js:1566:17)     加载http://localhost:5794/src/app/app.module时出错   " ./应用程序/ app.module"来自http://localhost:5794/src/main.js

看起来它显然与zone.js文件有关,但我无法解决这个问题。

systemjs.config.js代码:

    /**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
    System.config({
        paths: {
            // paths serve as alias
            'npm:': '/node_modules/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            'app': '/app',

            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

            // other libraries
            'rxjs': 'npm:rxjs',
            'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: 'main.js',
                defaultExtension: 'js',
                meta: {
                    './*.js': {
                        loader: 'systemjs-angular-loader.js'
                    }
                }
            },
            rxjs: {
                defaultExtension: 'js'
            }
        }
    });
})(this);

package.json代码:

    {
  "name": "angular-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "build": "tsc -p src/",
    "build:watch": "tsc -p src/ -w",
    "build:e2e": "tsc -p e2e/",
    "serve": "lite-server -c=bs-config.json",
    "serve:e2e": "lite-server -c=bs-config.e2e.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pree2e": "npm run build:e2e",
    "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
    "preprotractor": "webdriver-manager update",
    "protractor": "protractor protractor.config.js",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "pretest:once": "npm run build",
    "test:once": "karma start karma.conf.js --single-run",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/common": "~4.3.4",
    "@angular/compiler": "~4.3.4",
    "@angular/core": "~4.3.4",
    "@angular/forms": "~4.3.4",
    "@angular/http": "~4.3.4",
    "@angular/platform-browser": "~4.3.4",
    "@angular/platform-browser-dynamic": "~4.3.4",
    "@angular/router": "~4.3.4",

    "angular-in-memory-web-api": "~0.3.0",
    "systemjs": "0.19.40",
    "core-js": "^2.4.1",
    "rxjs": "5.0.1",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "concurrently": "^3.2.0",
    "lite-server": "^2.2.2",
    "typescript": "~2.1.0",

    "canonical-path": "0.0.2",
    "tslint": "^3.15.1",
    "lodash": "^4.16.4",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",

    "@types/node": "^6.0.46",
    "@types/jasmine": "2.5.36"
  },
  "repository": {}
}

main.ts code

    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app.module';

platformBrowserDynamic().bootstrapModule(AppModule);

app.module.ts代码:

    import { NgModule } from '@angular/core';
import { APP_BASE_HREF } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { routing } from './app.routing';
import { HomeComponent } from './components/home.component';


@NgModule({
    imports: [BrowserModule, ReactiveFormsModule, HttpModule, routing],
    declarations: [AppComponent, HomeComponent],
    providers: [{ provide: APP_BASE_HREF, useValue: '/' }],
    bootstrap: [AppComponent]
})

export class AppModule { }

app.component代码:

    import { Component } from "@angular/core"
@Component({
    selector: "user-app",
    template: `
               <div>
                  <nav class='navbar navbar-inverse'>
                       <div class='container-fluid'>
                         <ul class='nav navbar-nav'>
                           <li><a [routerLink]="['home']">Home</a></li>
                      </ul>
                      </div>
                 </nav>    
              <div class='container'>
                <router-outlet></router-outlet>
              </div>
             </div>          
`
})

export class AppComponent {

}

home.component.ts代码

import { Component } from "@angular/core";

@Component({
    template: `<img src="../../images/users.png" style="text-align:center"/>`
})

export class HomeComponent {
}

思想?

0 个答案:

没有答案