我能够正确地控制所有值的console.log,但是没有评估表达式img ng-src =“{{$ scope.bus}}”。我对angularJs很新,任何帮助都会很棒。下面是代码
$scope.showAdvanced = function (ev, bus) {
$scope.bus = bus;
console.log(bus);
console.log("scope.bus ="+$scope.bus);
$mdDialog.show({
controller: DialogController,
template: '<div role="dialog" aria-label="Eat me!" layout="column" layout-align="center center">' +
' <md-toolbar>' +
' <div class="md-toolbar-tools">' +
' <h2>Surprise!</h2>' +
' </div>' +
' </md-toolbar>' +
' ' +
' <div ' +
' <div id="slideDiv" class="demo-dialog-content">' +
' <div layout="row" >' +
' <img ng-src="{{$scope.bus}}">' +
' </div>' +
' </div>' +
' ' +
' <div layout="row" class="demo-dialog-button">' +
' <md-button md-autofocus flex class="md-primary" ng-click="cancel()">' +
' Close' +
' </md-button>' +
' </div>' +
' </div>',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: $scope.customFullscreen // Only for -xs, -sm breakpoints.
})
};
$ scope在这种情况下不起作用,因为它是一个孤立的。你能尝试添加当地人吗?谢谢。
locals: {bus: $scope.bus}
要么
以下是第一种方法。
locals: {parent: $scope}
$scope.showAdvanced = function (ev, bus) {
$scope.bus = bus;
console.log(bus);
console.log("scope.bus ="+$scope.bus);
$mdDialog.show({
controller: DialogController,
controllerAs: 'DialogCtrl',
template: '<div role="dialog" aria-label="Eat me!" layout="column" layout-align="center center">' +
' <md-toolbar>' +
' <div class="md-toolbar-tools">' +
' <h2>Surprise!</h2>' +
' </div>' +
' </md-toolbar>' +
' ' +
' <div ' +
' <div id="slideDiv" class="demo-dialog-content">' +
' <div layout="row" >' +
' <img ng-src="{{DialogCtrl.bus}}">' +
' </div>' +
' </div>' +
' ' +
' <div layout="row" class="demo-dialog-button">' +
' <md-button md-autofocus flex class="md-primary" ng-click="cancel()">' +
' Close' +
' </md-button>' +
' </div>' +
' </div>',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: $scope.customFullscreen // Only for -xs, -sm breakpoints.
})
};