1

I used checklist-model plugin for my project. It works well. But i need the output values without array brackets. For example if i chose 20 c checkbox in my code, it appeared with ["20 c"]. But here i need the output "20 c".

My html Code

<div ng-controller="Ctrl1" >
<label ng-repeat="temp in temps">
  <input type="checkbox" checklist-model="tempValue.temps" checklist-value="temp"> {{temp}}
</label><br />
<input type="text" value="{{tempValue.temps}}"  />
</div>

My Controller Code

app.controller('Ctrl1', function($scope) {
  $scope.temps = [
    '18 C ', 
    '19 C ', 
    '20 C ', 
    '21 C ',
    '22 C ', 
    '23 C ', 
    '24 C ', 
    '25 C ',
    '26 C ', 
    '27 C ', 
    '28 C ', 
    '29 C ',
    '30 C '
  ];
  $scope.tempValue = {
    temps: ['20 C ' , '24 C ' ]
  };

});
3
  • What about in the case where multiple checkboxes are selected? Do you want to write out "20 C " , "24 C " (comma delimited list)? Commented Aug 1, 2015 at 12:34
  • <input type="text" value="{{ tempValue.temps[0] }}" /> ?? Commented Aug 1, 2015 at 12:34
  • 1
    I want my output without brackets & double quotes. Just like 20 c, 24c Commented Aug 1, 2015 at 12:35

1 Answer 1

5

If you only want to show the first item the the $scope.tempValue array you can do this:

{{ tempValue.temps[0] }}

If you want all the values listed, split by some delimiter - in this example, a comma - you can do this:

{{ tempValue.temps.join(', ') }} 
Sign up to request clarification or add additional context in comments.

1 Comment

@BhavanKumarNatarajan if it works than you'd consider accepting this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.