[英]Handlebars angular JS parse error in ng-select
I have a ng-repeat div, and inside the div have select control. 我有一个ng-repeat div,并且在div内有select控件。 This code produces parse error:
此代码产生解析错误:
<select name="qty" ng-model="Qty">
<option ng-repeat="v in [1,2,3,4,5,6,7,8,9,10]"
value="{{v}}" ng-selected="v=={{item["menuItem.Qty"]}}">
{{v}}
</option>
</select>
In F12 console it prints ng-selected="{{item[" menuitem.qty"]}}"=""
在F12控制台中,它显示
ng-selected="{{item[" menuitem.qty"]}}"=""
So, I see there is an issue with handlebars and array, but just cannot figure out what exactly wrong here. 因此,我看到把手和数组存在问题,但无法弄清楚这里到底有什么问题。
Change 更改
ng-selected="v=={{item["menuItem.Qty"]}}"
To 至
ng-selected="v=={{item['menuItem.Qty']}}"
Here's a solution: 这是一个解决方案:
(function() { 'use strict'; angular.module('App', []) .controller('InputCtrl',['$scope', function($scope){ $scope.menuItem={}; $scope.menuItem.Qty = 1; $scope.item = {}; $scope.item[1] = 1; }]); }());
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"></script> <div ng-app="App" ng-controller="InputCtrl"> <select name="qty" ng-model="Qty" > <option ng-repeat="v in [1,2,3,4,5,6,7,8,9,10]" value="{{v}}" ng-bind="v" ng-selected="v==item[menuItem.Qty]"> </option> </select> Qty:{{Qty}}<br/> item:{{item}} </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.