0

AngularJs ng-pluralize into component didn't updated on model changes. ng-pluralize without component works fine On model update pluralize into index.html updated properly, and plural into component didn't update, although varaible into component updated.

Change value to 0,1,2 http://plnkr.co/edit/Csm3k9jaoQOXP52hF9HV

Plural Component:

function PluralComponent() {
    var ctrl = this;
    ctrl.number = 2;
}

angular.module('main',[]).component('pluralComponent', {
    templateUrl: 'PluralComponent.html',
    controller: PluralComponent,
    bindings: {
        number: "<",
    }
});

htmlComponent

<h1>Number {{$ctrl.number}}</h1>
Plural Component <ng-pluralize
    count="{{$ctrl.number}}"
    when-0="00"
    when-one="11"
    when-few="22"
    when-many="33"
    when-other="44">
</ng-pluralize>

index:

    <input type="number" ng-model="foo" ng-init="foo=1" />
    <hr/>
    <plural-component number="foo"></plural-component><hr/>
    Non Component <ng-pluralize
        count="foo"
        when-0="00"
        when-one="11"
        when-few="22"
        when-many="33"
        when-other="44">
    </ng-pluralize>

1 Answers1

2

Change your "PluralComponent.html" to

<h1>Number {{$ctrl.number}}</h1>
Plural Component <ng-pluralize
    count="$ctrl.number"
    when-0="00"
    when-one="11"
    when-few="22"
    when-many="33"
    when-other="44">
</ng-pluralize>
user4720824
  • 121
  • 4