angularjs – Angular-material md-select with images或svg

前端之家收集整理的这篇文章主要介绍了angularjs – Angular-material md-select with images或svg前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用角度材料,我想使用md-select但是使用images / svg;我正在使用md-option和ng-repeat,并且选项列表有效,但是当我选择某些内容时,我会看到文本.

这可行吗?

谢谢

<md-select ng-model="mkt.bookmaker" placeholder="Select a bookmaker">
  <md-option ng-value="opt" ng-repeat="opt in mkt.selected.matchInfo.bookmakers">
    <md-icon md-svg-src="{{ opt.logo }}"></md-icon>{{ opt.name }}
  </md-option>
</md-select>

这里有一些截图:

解决方法

我找到了一个在 angular material github中使用md-select的好方法

Here带有解决方案的plunker,并在预览下方.

控制器:

var app = angular.module('DemoApp',['ngMaterial']);

app.controller('MainCtrl',function($scope) {

    $scope.options = [
      {
        name: 'Rome',size: '200€',image: 'http://lorempixel.com/120/60/cats/'
      },{
        name: 'Naples',size: '230€',image: 'http://lorempixel.com/120/60/food/'
      }
      ];

      $scope.currOption =   $scope.options[1];

      $scope.updateData = function(){
        $scope.options = [
          {
            name: 'London',size: '400€',image: 'http://lorempixel.com/60/60/abstract/'
          },{
            name: 'Paris',size: '900€',image: 'http://lorempixel.com/60/60/nature/'
          },{
            name: 'Rome',image: 'http://lorempixel.com/60/60/sport/'
          },{
            name: 'Naples',image: 'http://lorempixel.com/60/60'
          }
          ];

          $scope.currOption =   $scope.options[1];
      }

});

我的Html:

<md-select data-ng-model="currOption">
      <md-select-label><img src="{{ currOption.image }}" /></md-select-label>
        <md-option data-ng-value="opt" data-ng-repeat="opt in options"><img src="{{ opt.image }}" /></md-option>
    </md-select>

猜你在找的Angularjs相关文章