When working with angular.js, I am dynamically generating options for a <select>
element using the ng-repeat directive.
Instead of using ng-options
, I opted for ng-repeat
because this is for an empty form where I needed to set default values for selected
and disabled
, as well as have a final option not in the model.
var form = {}; // This object will store form data, including form.boro
var boros = {"BK":"brooklyn","Q":"queens","NY":"manhattan","BX":"bronx","SI":"staten island"}
<select class='form-control capitalize' name="city" ng-model='form.boro' >
<option value="" >City</option>
<option ng-repeat="(k, val) in boros" value="{{k}}">{{val}}</option>
<option value='other'>Other</option>
</select>
Although this setup successfully generated the intended element and options, it caused the following error:
TypeError: Cannot read property '$$phase' of null
This error was triggered by setting value=""
in
<option value="">City</option>
The application continued to function without crashing, but I am interested in understanding why this occurs upon state exit and if there might be a mistake in my implementation.