AngularJs ng-pluralize成组件

时间:2016-03-15 08:38:03

标签: angularjs pluralize angularjs-ng-pluralize

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: "<",
    }
});

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>

指数:

    <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 个答案:

答案 0 :(得分:2)

将“PluralComponent.html”更改为

window.body