Ng-select在渲染数组列表时不起作用

ng-select doesn't work on rendering array list?

本文关键字:列表 不起作用 数组 Ng-select      更新时间:2023-09-26

不知道怎么回事,有线索吗?我发现使用ng-repeat不太好,尝试了ng-select,但没有渲染任何东西。

<select name="country" ng-model="user.country"
                  ng-options="country.name for country in country_list" >
              {{name}}
          </select>
$sope.country_list = [
      {name: 'Afghanistan', code: 'AF'}, 
      {name: 'Åland Islands', code: 'AX'}, 
      {name: 'Albania', code: 'AL'}, 
      {name: 'Algeria', code: 'DZ'}, 
      {name: 'American Samoa', code: 'AS'}, 
      {name: 'AndorrA', code: 'AD'}
];

你可以试试:

<select ng-options="country as country.name for country in country_list" ></select>

您有一个错别字$scope而不是$sope。参见工作演示

你有一个打字错误的第6行,$scope不是$sop