Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 使用图像或svg选择角度材质md_Angularjs_Svg_Angular Material - Fatal编程技术网

Angularjs 使用图像或svg选择角度材质md

Angularjs 使用图像或svg选择角度材质md,angularjs,svg,angular-material,Angularjs,Svg,Angular Material,我使用的是角度材质,我想使用md select,但要使用图像/svg;我将md选项与ng repeat一起使用,选项列表有效,但当我选择某个选项时,我会看到文本 可行吗 谢谢 {{opt.name} 我找到了一种在中使用md select的好方法 使用解决方案的plunker,下面是预览 控制器: var app = angular.module('DemoApp', ['ngMaterial']); app.controller('MainCtrl', function($scope)

我使用的是角度材质,我想使用md select,但要使用图像/svg;我将md选项与ng repeat一起使用,选项列表有效,但当我选择某个选项时,我会看到文本

可行吗

谢谢


{{opt.name}

我找到了一种在中使用md select的好方法

使用解决方案的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',
            size: '200€',
            image: 'http://lorempixel.com/60/60/sport/'
          },
          {
            name: 'Naples',
            size: '230€',
            image: 'http://lorempixel.com/60/60'
          }
          ];

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

});
    <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>
我的Html:

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',
            size: '200€',
            image: 'http://lorempixel.com/60/60/sport/'
          },
          {
            name: 'Naples',
            size: '230€',
            image: 'http://lorempixel.com/60/60'
          }
          ];

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

});
    <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>


对于Angular 2+,您可以使用
正下方的
并将选定对象的路径设置为
{{selected.name}}

这样您就只需要图像了?你能说得更清楚些吗?第一张照片还可以;这就是我想要的;问题出现在第二张图片中:我想在选中某个对象后也看到该图像。希望现在更清楚了。拍一拍。包括图像