ngOption 有用过ngOption的同学吗?
发布于 1年前 作者 maxer028 805 次浏览 来自 问答
PEROID: <select ng-model="myPeroid" ng-selected="xx" ng-options="peroid for peroid in peroids"></select>
      $scope.peroids = [
        '10 min',
        '30 min',
         '60 min',
         '90 min',
         '120 min'
    ];
    ngOption怎么设置初值?及怎么获取选取的值,用$scope.myPeroid 取出来未定义?谢谢
2 回复

html

 <select ng-model="topicsData.tab"
     ng-options="tab.value as tab.label for tab in tabs">
</select>

controller

 $scope.tabs = [{
            value: 'share',
            label: '分享'
        }, {
            value: 'ask',
            label: '问答'
        }, {
            value: 'job',
            label: '招聘'
        }, {
            value: 'bb',
            label: '吐槽'
        }];
 
 // 默认值
 $scope.topicsData.tab='share';
回到顶部