首先,這個問題是而不是重複的,大多數問題的答案都是「無法綁定到x」。 「關於未導入的模塊,我已經已經輸入了正確的那個。Angular2:無法綁定到'ngPluralCase',因爲它不是'x'的已知屬性
我下面angular.io的doc約ngPlural
和ngPluralCase
指令:
<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
我看到你打開的問題,良好的通話。出於某種原因,我沒有像這樣使用它,但成功地使用它,如''(也有點短)。一個問題[here](https:// stackoverflow。com/questions/39547858/angular-2-ng-container)仍然沒有公平的答案。 – estus