angularjs - How to fix this expression -
i trying print multiple *
based on rating value. in javascript console array(10).join('*')
produces 10 stars. when using in angularjs view, expression not evaluated. missing something?
<div data-ng-controller="skillscontroller"> <ul> <li data-ng-repeat="skill in skills">{{skill.name}} - {{array(skill.rating).join('*')}}</li> </ul> </div>
app.js
app.controller('skillscontroller', function($scope){ $scope.skills = [ { name: 'ruby', rating: 5 }, { name: 'java', rating: 10} ]; })
array not part of $scope. can following in controller.
app.controller('skillscontroller', function($scope){ $scope.skills = [ { name: 'ruby', rating: 5 }, { name: 'java', rating: 10} ]; $scope.array = array; });
i transformation in filter or directive.
app.filter('stars', function() { return function(input) { return array(input).join('*'); }; });
and then
{{skill.rating | stars}}
Comments
Post a Comment