angular2 directives - Can't get ngPlural to work Angular -


i'm trying ngplural work using angular version 4.0.3 stated in api: https://angular.io/api/common/ngplural

<some-element [ngplural]="value">   <ng-template ngpluralcase="=0">there nothing</ng-template>   <ng-template ngpluralcase="=1">there one</ng-template>   <ng-template ngpluralcase="few">there few</ng-template> </some-element> 

when use [ngplural] error no provider templateref! template ref. if remove , use *ngplural error no provider ngplural!

i don't think need add provider it's angular common library *ngif , *ngfor , work after connecting commons library.

are docs date v4.0.3?
how can work in template?

update:

i have added plunker showcase problem: https://plnkr.co/edit/sqwrwjvejjpqmvkwo1g4?p=preview

you can use expanded form like:

<div [ngplural]="value" class="testparent">    <ng-template ngpluralcase="=0">       <square class="testbox1"></square>    </ng-template>    <ng-template ngpluralcase="=1">      111    </ng-template> </div> 

plunker example

or short form:

{ value, plural, =0 {<square class="testbox1"></square>} =1 {111} } 

plunker example


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -