0

AngularJs ng-pluralize into component 没有在模型更改时更新。没有组件的 ng-pluralize 工作正常在模型更新时,将复数化为 index.html 已正确更新,而复数到组件未更新,尽管组件已更新。

将值更改为 0,1,2 http://plnkr.co/edit/Csm3k9jaoQOXP52hF9HV

复数成分:

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

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

html组件

<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>

指数:

    <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>
4

1 回答 1

2

将您的“PluralComponent.html”更改为

<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>
于 2016-03-15T09:09:37.723 回答