2016-10-18 43 views
2

首先,這個問題是而不是重複的,大多數問題的答案都是「無法綁定到x」。 「關於未導入的模塊,我已經已經輸入了正確的那個Angular2:無法綁定到'ngPluralCase',因爲它不是'x'的已知屬性

我下面angular.io的doc約ngPluralngPluralCase指令:

<some-element [ngPlural]="value"> 
    <ng-container *ngPluralCase="'=0'">...</ng-container> 
    <ng-container *ngPluralCase="'other'">...</ng-container> 
</some-element> 

(...)

從@角/普通/指數,定義導出@角/通用/ src目錄/指令/ ng_plural.ts

當我嘗試運行此代碼我得到一個錯誤(see it in plnkr)

無法綁定到'ngPluralCase',因爲它不是'ng-container'的已知屬性。

main.ts:

import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; 
import { Component, NgModule } from "@angular/core"; 
import { BrowserModule } from "@angular/platform-browser"; 

@Component({ 
    selector: "my-app", 
    template:` 
    <div [ngPlural]="1"> 
     <ng-container *ngPluralCase="'=0'">...</ng-container> 
     <ng-container *ngPluralCase="'other'">...</ng-container> 
    </div> 
    `, 
    styles: [] 
}) 
class AppComponent { 

} 

@NgModule({ 
    imports: [ 
    BrowserModule 
    ], 
    declarations: [AppComponent], 
    exports: [AppComponent], 
    bootstrap: [AppComponent] 
}) 
class AppModule { } 


platformBrowserDynamic().bootstrapModule(AppModule); 

我進口BrowserModule(其中出口CommonModule,但我也試過進口CommonModule直接)在我AppModule,正如你所看到的,誤差約爲ngPluralCase而不是ngPlural這是在同一模塊,並沒有問題...

所以我的問題是:

有誰知道這裏發生了什麼?這是一個與這些指令的「實驗性」狀態相關的錯誤還是我錯過了某些東西?

PS:我使用的角度V2.1.0

+0

我看到你打開的問題,良好的通話。出於某種原因,我沒有像這樣使用它,但成功地使用它,如'