SyntaxError:意外的令牌< ng2 bootstrap

时间:2017-01-15 06:52:33

标签: jquery twitter-bootstrap angular ng2-bootstrap

我正在使用ng2 bootstrap,我遇到错误意外令牌< 下面是配置文件,我添加了'ng2-bootstrap':'node_modules / ng2-bootstrap'

System.config.ts

struct MessageBase
{
    // The function to send *this* message to the receiver
    virtual void send(ReceiverClass*) = 0;
};

struct MessageInt : MessageBase
{
    int payload;

    void send(ReceiverClass* receiver)
    {
        // Code to send this message type to the receiver...
    }
};

struct MessageString : MessageBase
{
    std::string payload;

    void send(ReceiverClass* receiver)
    {
        // Code to send this message type to the receiver...
    }
};

// ...

// Vector to store the messages
std::vector<MessageBase*> messages;

// Add a couple of messages
messages.push_back(new MessageInt{123});
messages.push_back(new MessageString{"Foobar"});

// Send the message to some receiver
for (auto const* message : messages)
    message->send(some_reciver_object);

以下是我导入的模块文件 AlertModule.forRoot()

Module.ts

(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',
            'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
            'ng2-bootstrap': 'node_modules/ng2-bootstrap'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            },
            'angular2-in-memory-web-api': {
                main: './index.js',
                defaultExtension: 'js'
            }
        }
    });
})(this);

我使用的来源https://valor-software.com/ng2-bootstrap/#/alerts

2 个答案:

答案 0 :(得分:0)

在你的systemjs.config.js中替换

'ng2-bootstrap': 'node_modules/ng2-bootstrap'

这一行

'ng2-bootstrap': 'npm:ng2-bootstrap/bundles/ng2-bootstrap.umd.min.js'

您只是提供错误文件的路径

答案 1 :(得分:0)

在systemJS属性中配置它:

var map = {
    ...
    'ng2-bootstrap':              'npm:ng2-bootstrap',
  };

var packages = {
   ...
  'ng2-bootstrap': { format: 'cjs', main: 'bundles/ng2-bootstrap.umd.js', defaultExtension: 'js' },
  ...
 };