AngularJS: Trying to create a dynamic dropdown -
I am trying to create a dynamic dropdown this year and the next 3 years which will be automatically modified as the year's change Will be updated from I am getting an unexpected token error with this attempt:
Controller:
$ scope.thisYear = new date (). GetFullYear (); $ Scope.year_span = [{'id' = & gt; $ Scope.this year, 'year' = & gt; $ Scope.thisYear}, {'id' = & gt; $ Scope.thisYear + 1, 'year' = & gt; $ Scope.thisYear + 1}, {'id' = & gt; $ Scope.thisYear + 2, 'year' = & gt; $ Scope.thisYear + 2}, {'id' = & gt; $ Scope.thisYear + 3, 'year' = & gt; $ Scope.thisYear + 3}];
HTML:
& lt; Div class = "form-group col-md-4" & gt; & Lt; Label & gt; Crop year: & lt; / Labels & gt; & Lt; Select name = "crop_year" ng-model = "afmdata.lonecop_year" class = "form-control" ng-options = "ys.year year_span for ys as of year" & gt; & Lt; Option value = "" & gt; Please select ... & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Div & gt;
It should be
$ scope Year_span = [{'Id': $ scope.this year, 'year': $ scope.thisYear}, {'id': $ scope.this year 1, 'year': $ scope.thisYear + 1}, {'id ': $ Scope.this year + 2,' year ': $ scope.this year + 2}, {' id ': $ scope.this year + 3,' year ': $ scope.thisYear + 3}];
The correct syntax for the object is {key: value}
Comments
Post a Comment