asp.net core / angular4未处理的Promise拒绝:没有ApplicationRef的提供者

时间:2017-08-07 08:00:13

标签: asp.net angular webpack asp.net-core

尝试将angular4用于asp.net核心项目。

使用此回购https://github.com/cadabloom/AspNetCoreAngular进行角度诱惑。

不知道是什么导致它,有没有办法获得有关此错误类型的更多详细信息?

收到此错误。

Access-Control-Allow-Origin

home.components.ts

vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:83954 Unhandled Promise rejection: No provider for ApplicationRef! ; Zone: <root> ; Task: Promise.then ; Value: Error: No provider for ApplicationRef!
    at injectionError (vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:12189)
    at noProviderError (vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:12227)
    at ReflectiveInjector_._throwOrNull (vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:13728)
    at ReflectiveInjector_._getByKeyDefault (vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:13767)
    at ReflectiveInjector_._getByKey (vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:13699)
    at ReflectiveInjector_.get (vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:13568)
    at AppModuleInjector.createInternal (module.ngfactory.js? [sm]:1)
    at AppModuleInjector.NgModuleInjector.create (vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:14495)
    at NgModuleFactory.create (vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:14468)
    at vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:15709 Error: No provider for ApplicationRef!
    at injectionError (http://localhost:5000/dist/vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:12189:86)
    at noProviderError (http://localhost:5000/dist/vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:12227:12)
    at ReflectiveInjector_._throwOrNull (http://localhost:5000/dist/vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:13728:19)
    at ReflectiveInjector_._getByKeyDefault (http://localhost:5000/dist/vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:13767:25)
    at ReflectiveInjector_._getByKey (http://localhost:5000/dist/vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:13699:25)
    at ReflectiveInjector_.get (http://localhost:5000/dist/vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:13568:21)
    at AppModuleInjector.createInternal (ng:///AppModule/module.ngfactory.js:122:51)
    at AppModuleInjector.NgModuleInjector.create (http://localhost:5000/dist/vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:14495:76)
    at NgModuleFactory.create (http://localhost:5000/dist/vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:14468:18)
    at http://localhost:5000/dist/vendor.js?v=8G5nuphpleAMB8hDVj0v8l9es64guglhqGWIwYdey3M:15709:61

promoslidercomponent.ts

import { Component, NgModule} from '@angular/core';
import { PromoSliderComponent } from './promoslider.component';


@Component({
    selector: 'home',
    templateUrl: '/home.component.html'
})

@NgModule({
    declarations: [],  
    providers: [],
    bootstrap: [],
    imports: [PromoSliderComponent],
    schemas: []
})

export class HomeComponent {

}

app.module.shared.ts

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

@Component({
    selector: 'promo-slider',
    templateUrl: './promoslider.component.html'
})
export class PromoSliderComponent {
}

addp.module.client.ts

import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { AppComponent } from './components/app/app.component'
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { FooterComponent } from './components/footer/footer.component';
import { HomeComponent } from './components/home/home.component';
import { PromoSliderComponent } from './components/home/promoslider.component';


export const sharedConfig: NgModule = {
    bootstrap: [ AppComponent ],
    declarations: [
        AppComponent,
        NavMenuComponent,
        FooterComponent,
        PromoSliderComponent,
        HomeComponent

    ],
    imports: [
        RouterModule.forRoot([
            { path: '', redirectTo: 'home', pathMatch: 'full' },
            { path: 'home', component: HomeComponent },
            { path: '**', redirectTo: 'home' }
        ]) 
    ],
};

问题2:在asp.net核心项目中使用angular使我无法使用组件而不是部分。有没有办法使用角度偏?我不想从服务中获取所有数据,或者我必须这样做?

0 个答案:

没有答案