错误:select中不允许重复的md-option值。找到重复值“0.5 track by $ index”

时间:2016-11-14 08:24:01

标签: javascript angularjs

我正在按照此链接中的ng-repeat说明进行操作

Angular ng-repeat Error "Duplicates in a repeater are not allowed."

但在我的情况下,我在我的组合框中使用ng-repeat

这是我的视图代码(超薄格式)

md-input-container flex="50"
  label Period
  md-select name="type" ng-model="period"
    md-option ng-repeat=" period in periods track by $index" value="{{period.value}} track by $index"
      | {{period.name}}

这是我的控制器(咖啡脚本格式)

  $scope.periods = [{ "id": 1 ,"value": 1.0 , "name": "amtopm" }, { "id": 2 , "value": 0.5 , "name": "amtoam" }, { "id": 3 , "value": 0.5 , "name": "pmtopm" }]

这可以解决吗?

我的错误

Error: Duplicate md-option values are not allowed in a select. Duplicate value "0.5 track by $index" found.
at SelectMenuController.self.addOption (http://localhost:3000/assets/angular-material/angular-material.self-7da646f…0d815a4ab7457c1721ae7fe722ebb2b821ed2e8edb4651da9af5159.js?body=1:17597:15)
at setOptionValue (http://localhost:3000/assets/angular-material/angular-material.self-7da646f…0d815a4ab7457c1721ae7fe722ebb2b821ed2e8edb4651da9af5159.js?body=1:17769:18)
at Object.postLink (http://localhost:3000/assets/angular-material/angular-material.self-7da646fa80d815a4ab7457c1721ae7fe722ebb2b821ed2e8edb4651da9af5159.js?body=1:17719:7)
at http://localhost:3000/assets/angular/angular.self-7f8df3e3ebe7623e233b951726e7da238883fa9e7a98b987ac7aecccf5f00510.js?body=1:1248:18
at invokeLinkFn (http://localhost:3000/assets/angular/angular.self-7f8df3e3ebe7623e233b951726e7da238883fa9e7a98b987ac7aecccf5f00510.js?body=1:9935:9)
at nodeLinkFn (http://localhost:3000/assets/angular/angular.self-7f8df3e3ebe7623e233b951726e7da238883fa9e7a98b987ac7aecccf5f00510.js?body=1:9336:11)
at compositeLinkFn (http://localhost:3000/assets/angular/angular.self-7f8df3e3ebe7623e233b951726e7da238883fa9e7a98b987ac7aecccf5f00510.js?body=1:8621:13)
at publicLinkFn (http://localhost:3000/assets/angular/angular.self-7f8df3e3ebe7623e233b951726e7da238883fa9e7a98b987ac7aecccf5f00510.js?body=1:8501:30)
at lazyCompilation (http://localhost:3000/assets/angular/angular.self-7f8df3e3ebe7623e233b951726e7da238883fa9e7a98b987ac7aecccf5f00510.js?body=1:8845:25)
at boundTranscludeFn (http://localhost:3000/assets/angular/angular.self-7f8df3e3ebe7623e233b951726e7da238883fa9e7a98b987ac7aecccf5f00510.js?body=1:8638:16) <md-option ng-repeat=" period in periods track by $index" value="{{period.value}} track by $index" tabindex="0" class="ng-scope" data-ng-animate="1">

0 个答案:

没有答案