我試圖將一個Ng重複傳遞給我的$mdDialog
,但是我沒有找到有關如何執行的文檔。我一直指的是This Stack,但我沒有把圖像傳遞給模態。
在我收到一個錯誤說控制檯:
TypeError: Cannot read property 'element' of undefined
什麼是控制檯錯誤的原因和圖像不及格的模式?
HTML
<md-grid-tile
ng-repeat="image in imageBucket.images"
md-rowspan="{{image.row}}"
md-rowspan-gt-lg="{{image.rowgtlg}}"
md-colspan="{{image.col}}"
md-colspan-gt-lg="{{image.colgtlg}}"
class="white" >
<md-button
class=""
ng-click="showAdvanced($event, image)"
flex="100"
flex-gt-md="auto">
<img
aria-label="kpinsonstairs"
class="img-responsive md-whiteframe-6dp"
src="{{image.src}}"
alt="Gallery Picture">
<md-grid-tile-footer>
<h3>{{image.title}}</h3>
</md-grid-tile-footer>
</md-button>
</md-grid-tile>
的Javascript
(function() {
'use strict';
angular
.module('resonance.gallery.controllers')
.controller('GalleryOneController', GalleryOneController);
GalleryOneController.$inject = [
'$scope',
'$mdDialog',
'ImageService'
];
function GalleryOneController($scope, $mdDialog, ImageService) {
ImageService.success(function(data) {
$scope.imageBucket = data;
});
$scope.showAdvanced = function(ev, image) {
$mdDialog.show({
clickOutsideToClose:true,
controller: function($mdDialog) {
var vm = this;
var image = {};
var image = image;
$scope.hide = function() {
$mdDialog.hide();
}
$scope.cancel = function() {
$mdDialog.cancel();
};
},
controllerAs: 'modal',
templateUrl: 'client/gallery/views/dialog.ng.html',
parent: angular.element(document.body),
targetEvent: ev
});
};
}
})();
HTML模式
<img
class="img-responsive md-whiteframe-6dp"
src="{{modal.image.src}}"
alt="Gallery Picture">
如果你想訪問html中的圖像,不應該是vm.image = image? –
@KarthikRP不,這並不能解決問題。 –