question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AngularJS: spaces in <option> value attr with ng-repeat

See original GitHub issue

From https://github.com/yeoman/generator-angular/issues/1052

My controller has

$scope.opts = [
        "opt1",
        "opt2",
        "opt3",
        "opt4",
        "opt5"
    ];
$scope.opt = "opt1";

The view is like the following

<select ng-model="opt">
    <option value="">...</option>
    <option ng-repeat="option in opts">{{option}}</option>
</select>

Using grunt serve there are no problems and the result is:

opt

When I run grunt build the result is

<select>
    <option value="">...</option>
    <option value="opt1 ">opt1 </option>
    <option value="opt2 ">opt2 </option>
    <option value="opt3 ">opt3 </option>
    <option value="opt4 ">opt4 </option>
    <option value="opt5 ">opt5 </option>
</select>

White spaces? Why?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
hoatlecommented, Jun 24, 2015

I’m facing the same problem.

0reactions
alexlamslcommented, Feb 20, 2016

This should now be fixed in 1.2.0 on npm. If any of you still encounter the problem please reopen this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Additional spaces in angularjs select option - Stack Overflow
Try to put your code in one line. Something like that : <select name="recName" ng-model="newMessage.recName"> <option ng-repeat="player in ...
Read more >
Angular ng-options Directive - W3Schools
The ng-options directive uses an array to fill the dropdown list. In many cases it would be easier to use the ng-repeat directive,...
Read more >
ngRepeat - AngularJS: API
The ngRepeat directive instantiates a template once per item from a collection. Each template instance gets its own scope, where the given loop...
Read more >
How to filter ng-repeat values according to ng-model using ...
The ng-repeat values can be filtered according to the ng-model in AngularJS by using the value of the input field as an expression...
Read more >
Top 18 Most Common AngularJS Developer Mistakes - Toptal
In this article you will learn about most common AngularJS developer mistakes and how ... There are two ways, in both of them...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found