【问题标题】:Angular2 updateAngular2 更新
【发布时间】:2017-06-27 06:19:30
【问题描述】:

我将 angular2 更新到最新版本,我也将我的 nodejs 更新到 v6.9.5

在我这样做之后,我得到了下一个错误

错误中的错误遇到静态解析符号值。 不支持表达式形式(原始 .ts 中的位置 14:3 文件),解析符号字典 C:/NodeJs/analytics/client/src/app/translate/translations.ts, 解析符号 TRANSLATI ON_PROVIDERS 中 C:/NodeJs/analytics/client/src/app/translate/translations.ts, 解析 C:/Node 中的符号 TRANSLATION_PROVIDERS js/analytics/client/src/app/translate/index.ts,解析符号 C:/NodeJs/analytics/client/src/app/app.module.ts 中的 AppModule, 解析符号 AppModule 中 C:/NodeJs/analytics/client/src/app/app.module.ts

有时我的项目有效,但我不明白问题出在哪里。有人可以帮我解决这个问题吗

这是我的 app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule,ReactiveFormsModule }   from '@angular/forms';
import { HttpModule }    from '@angular/http';
import { MdCoreModule } from '@angular2-material/core';
import { MdButtonModule } from '@angular2-material/button';
import { MdButtonToggleModule } from '@angular2-material/button-toggle';
import { MdCardModule } from '@angular2-material/card';
import { MdRadioModule } from '@angular2-material/radio';
import { MdCheckboxModule } from '@angular2-material/checkbox';
import { MdTooltipModule } from '@angular2-material/tooltip';
import { MdInputModule } from '@angular2-material/input';
import { MdToolbarModule } from '@angular2-material/toolbar';
import { MdTabsModule } from '@angular2-material/tabs';
import { MdSidenavModule } from '@angular2-material/sidenav';
import { MdProgressCircleModule } from '@angular2-material/progress-circle';
import { AppComponent } from './app.component';
import "hammerjs";
import { routing,  appRoutingProviders } from './app.routes';
import {RouterModule} from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { IndexComponent } from './index/index.component';
import { LoginComponent } from './login/login.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { IndexService }          from './services/index.service';
import { HttpClient }          from './services/http.client';
import { AuthenticationService }   from './services/authentication.service';
import { AuthGuard } from './_guard/auth-guard';
import { ErrorMessageComponent } from './error-message/error-message.component';

import { MenuComponent } from './menu/menu.component';
import { PageAnalysisComponent } from './page-analysis/page-analysis.component';
import { SettingsComponent } from './settings/settings.component';
import { SiteVsSiteComponent } from './site-vs-site/site-vs-site.component';
import { SidenavComponent } from './sidenav/sidenav.component';
import { SitesListComponent } from './sites-list/sites-list.component';
import { SeoOverviewComponent } from './seo-overview/seo-overview.component';
import { AnalysisContentComponent } from './analysis-content/analysis-content.component';
import { DesignComponent } from './design/design.component';
import { PerformanceComponent } from './performance/performance.component';
import { CheckerComponent } from './checker/checker.component';
import { Loading } from './loading/loading.component';
import { TRANSLATION_PROVIDERS, TranslatePipe, TranslateService }   from './translate';
import { ChartModule } from 'angular2-highcharts';
import {FacebookService} from 'ng2-facebook-sdk/dist';
import { MdUniqueSelectionDispatcher } from '@angular2-material/core';
import { FormBuilder, Validators} from '@angular/forms';
import { AccessibilityComponent } from './accessibility/accessibility.component';
import { SummaryComponent } from './summary/summary.component';
import { CloudComponent } from './cloud/cloud.component';
import { RemoveSpacesPipe } from './remove-spaces.pipe';
import { ActivationComponent } from './activation/activation.component';

@NgModule({
  declarations: [
    AppComponent,
    DashboardComponent,
    IndexComponent,
    LoginComponent,
    NotFoundComponent,
    ErrorMessageComponent,
    MenuComponent,
    PageAnalysisComponent,
    SettingsComponent,
    SiteVsSiteComponent,
    SidenavComponent,
    SitesListComponent,
    SeoOverviewComponent,
    AnalysisContentComponent,
    DesignComponent,
    PerformanceComponent,
    CheckerComponent,
    TranslatePipe,
    AccessibilityComponent,
    SummaryComponent,
    CloudComponent,
    RemoveSpacesPipe,
    Loading,
    ActivationComponent
  ],

  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    RouterModule,
    routing,
    MdCoreModule,
    MdCardModule,
    MdButtonModule,
    MdRadioModule,
    ChartModule,
    MdCheckboxModule,
    MdTooltipModule,
    MdInputModule,
    MdToolbarModule,
    MdButtonToggleModule,
    MdTabsModule,
    MdSidenavModule,
    MdProgressCircleModule,
    MdRadioModule,
    ReactiveFormsModule
  ],
  providers: [appRoutingProviders,
              FacebookService,
              IndexService,
              TRANSLATION_PROVIDERS,
              TranslateService,
              AuthenticationService,
              MdUniqueSelectionDispatcher,
              FormBuilder,
              Validators,
              AuthGuard,
              HttpClient
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
}

【问题讨论】:

  • 您的应用模块中有什么?例如提供者等
  • 这是我的 app.module ` @NgModule({ 声明:[ AppComponent, NotFoundComponent],导入:[ BrowserModule,FormsModule,HttpModule,outerModule ],提供者:[appRoutingProviders,FacebookService,IndexService,TRANSLATION_PROVIDERS, TranslateService, AuthenticationService, MdUniqueSelectionDispatcher, FormBuilder, Validators, AuthGuard, HttpClient ], bootstrap: [AppComponent] }) 导出类 AppModule { }
  • app.module.ts 代码在哪里?
  • 我在评论中添加了
  • TRANSLATION_PROVIDERS 导致问题

标签: node.js angular


【解决方案1】:

变化

// app/translate/translations.ts
...
// all traslations
const dictionary = {
    [LANG_EN_NAME]: LANG_EN_TRANS,
    [LANG_ES_NAME]: LANG_ES_TRANS,
    [LANG_ZH_NAME]: LANG_ZH_TRANS,
};

// app/translate/translations.ts
...
// all traslations
const dictionary = {};
dictionary[LANG_EN_NAME] = LANG_EN_TRANS;
dictionary[LANG_ES_NAME] = LANG_ES_TRANS;
dictionary[LANG_ZH_NAME] = LANG_ZH_TRANS;

为我解决了这个问题。我不知道为什么。

另外我建议直接导入或使用模块而不是使用桶(index.ts)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-14
    • 2017-06-11
    相关资源
    最近更新 更多