AngularJs ng-复数化为组件

AngularJs ng-pluralize into component

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>

将您的 "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>