HLJ 发布于
2018-08-17 14:35:54

AngularJS处理ng-options首项空白代码

上一篇文章:

AngularJS定时器

AngularJS处理ng-options首项空白代码
html代码:
<body ng-app="myApp" ng-controller="myCtrl">
  <div>
    选择内容:
    <select ng-model="selectedPeople" ng-options="v.name for v in people"></select>
    <p>ng-repeat解决首项空白:</p>
    <select>
      <option ng-repeat="v in people">{{ v.name }}</option>
    </select>
    <p>ng-options解决首项空白:</p>
    <select ng-model="selectedYourPeople" ng-options="v.name as v.name for v in people"></select>
  </div>
</body>
JavaScript代码:
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  console.log(9999)
$scope.people = [
    {id: 0,name: 'php',},
    {id: 1,name: 'JavaScript',},
    {id: 2,name: 'Java',},
    {id: 3,name: 'c#',}
  ];
  $scope.selectedYourPeople = $scope.people[0].name;
});
</script>
当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2018-08-17/121.html
最后生成于 2023-06-18 18:37:24
上一篇文章:

AngularJS定时器

此内容有帮助 ?
0