Angular ng2 typeahead和browserify:意外值';提前输入';由模块';AppModule';
这件事我已经操心好几天了。我尝试了此解决方案,但不完全适用:。这是我的第一个项目,所以我可能在做一些愚蠢的事情 我正在尝试浏览一个使用Typeahead的应用程序。当我运行它时,一切都很好,但不幸的是,我的应用程序相当大,我需要削减很多。当我这样做时,我会收到一个错误,应用程序无法工作。我已经在typeahead文档页面上浏览了无数次示例,并从中复制粘贴以避免打字错误,但它不起作用。下面是我的错误,下面是我的smallish app.module.ts和system.config.js 13:22:43.808错误:(SystemJS)模块“AppModule”声明的意外值“Typeahead” [16]https://pluto.probono.net/scripts/related-content/app/bundle.js:18801:33 [16]https://pluto.probono.net/scripts/related-content/app/bundle.js:18788:19 [16]https://pluto.probono.net/scripts/related-content/app/bundle.js:21478:26 [16] 编译模块和组件@ [16]https://pluto.probono.net/scripts/related-content/app/bundle.js:21407:18 [17] bootstrapModuleWithZone@ [17]https://pluto.probono.net/scripts/related-content/app/bundle.js:29080:20Angular ng2 typeahead和browserify:意外值';提前输入';由模块';AppModule';,angular,Angular,这件事我已经操心好几天了。我尝试了此解决方案,但不完全适用:。这是我的第一个项目,所以我可能在做一些愚蠢的事情 我正在尝试浏览一个使用Typeahead的应用程序。当我运行它时,一切都很好,但不幸的是,我的应用程序相当大,我需要削减很多。当我这样做时,我会收到一个错误,应用程序无法工作。我已经在typeahead文档页面上浏览了无数次示例,并从中复制粘贴以避免打字错误,但它不起作用。下面是我的错误,下面是我的smallish app.module.ts和system.config.js 13:2
[9] 像这样尝试-
从'ng2typeahead/src/ng2typeahead'导入{Typeahead}代码>谢谢。试着这样做,我发现我收到了与以前相同的错误消息。你能尝试使用官方网站上的快速入门示例使用ng2 typeahead
吗?这将帮助您确定确切的问题。谢谢您的建议。我已经到了最后期限,真的没有时间把这件事搞得这么严重。我发现(但有几个问题)我可以在短时间内实现Priming autocomplete,并且能够轻松地浏览它。
import { enableProdMode } from '@angular/core';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { ScheduleModule } from 'primeng/components/schedule/schedule';
import { CookieService } from 'angular2-cookie/services/cookies.service';
import { AppComponent } from './app.component';
import { EllipsisPipe } from './ellipsis.pipe';
import { ContentDisplayComponent } from './content-display.component';
import { ContentItemService } from './content-item.service';
import { Typeahead } from 'ng2-typeahead';
import { APP_BASE_HREF } from '@angular/common';
enableProdMode();
@NgModule({
imports: [ BrowserModule, HttpModule, ScheduleModule, FormsModule ],
providers: [ CookieService ],//, ActivatedRoute
declarations: [ AppComponent, ContentDisplayComponent, EllipsisPipe,
Typeahead ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
(function (global) {
if(window.location.hostname === "localhost") {
basePath = "";
} else {
basePath = "/scripts/related-content/";
}
System.config({
paths: {
// paths serve as alias
'npm:': basePath + 'node_modules/',
'': basePath
},
// 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',
'moment': 'npm:moment',
'primeng': 'npm:primeng',
'ng2-typeahead': 'npm:ng2-typeahead',
'angular2-cookie': 'npm:angular2-cookie'
},
packages: {
app: {
main: './bundle',/*main.min*/
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
},
'moment': {
main: 'moment.js',
defaultExtension: 'js'
},
'primeng': {
main: "primeng",
defaultExtension: 'js'
},
'angular2-cookie': {
main: "./core",
defaultExtension: 'js'
},
'ng2-typeahead': {
main: 'ng2-typeahead.js',
defaultExtension: 'js'
}
// 'ng2-typeahead': {
// main: './index',
// defaultExtension: 'js'
// }
}
});
})(this);