无法在我的angular-2快速入门应用程序中加载ng2-fullpage [英] Unable to load ng2-fullpage in my angular-2 quickstart app

查看:104
本文介绍了无法在我的angular-2快速入门应用程序中加载ng2-fullpage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用整页+ angular2:

I am trying to use full page + angular2:

我莫名其妙地无法加载ng2-fullpage软件包以供使用, 以下是我的文件:

I am somehow unable to load the ng2-fullpage package to use, below are my files:

systemjs.config.js

(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',
      // '@jquery':'npm:jquery/jquery.min.js',

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

app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {HttpModule} from '@angular/http';
import {routing} from './app.routing';
import {NavbarComponent} from './components/navbar/navbar.component';
import { MnFullpageDirective, MnFullpageService } from 'ng2-fullpage/ng2-fullpage';

import { AppComponent }  from './app.component';
import { ResumeComponent } from './components/resume/resume.component';
import { AboutComponent } from './components/about/about.component';
import {HomeComponent} from './components/home/home.component'



@NgModule({
  imports:      [ BrowserModule,HttpModule, routing ],
  declarations: [ AppComponent, ResumeComponent, AboutComponent, HomeComponent, NavbarComponent,MnFullpageDirective],
  bootstrap:    [ AppComponent ],
  providers: [MnFullpageService]
})
export class AppModule { }

对于ng2-fullpage,我的node_modules文件夹结构如下:

my node_modules folder structure is like below for ng2-fullpage:

我得到的错误是:

在我的网络标签中,当我单击ng2-fullpage时,我得到以下信息:

in my network tab I get the below when I click ng2-fullpage:

Cannot GET /node_modules/ng2-fullpage/ng2-fullpage

我一直在尝试使用npm页面上提供的plunkr解决此问题,该页面似乎可以工作,但对我不起作用. plunkr页面是

I have been trying to resolve this issue using the plunkr given on the npm page where it seems to work, but its not working for me. The plunkr page is

[ http://embed.plnkr.co/1p9zKp4CNI1HncAh1h9m][2]

控制台错误:

GET http://localhost:3000/node_modules/ng2-fullpage/ng2-fullpage 404 (Not Found)

"(SystemJS) XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-fullpage/ng2-fullpage
    Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-fullpage/ng2-fullpage
        at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js:1190:29) [<root>]
        at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:166:47) [<root> => <root>]
        at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:416:38) [<root>]
    Error loading http://localhost:3000/node_modules/ng2-fullpage/ng2-fullpage as "ng2-fullpage/ng2-fullpage" from http://localhost:3000/app/app.module.js"

推荐答案

我遇到了同样的问题,我通过在 systemjs.config.js 文件的部分中添加以下代码来解决此问题>软件包

I've got the same problem and I solve it by adding code below to systemjs.config.js file, section packages

  packages: {
          app: {
            defaultExtension: 'js'
          },
          'ng2-fullpage': {
            main: './index.js',
            defaultExtension: 'js'
          },
          rxjs: {
            defaultExtension: 'js'
          }
    }

这篇关于无法在我的angular-2快速入门应用程序中加载ng2-fullpage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆