2016-03-15 3 views
0

AngularJs ng-pluralize в компонент не обновлялся при изменении модели. ng-pluralize без компонента работает нормально При обновлении модели pluralize в index.html обновляется должным образом, а множественное число в компонент не обновлялось, хотя можно было изменить компонент.AngularJs ng-pluralize в компонент

Изменение значения для 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> 

ответ

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

Спасибо, что это работа. – user3706408

Смежные вопросы