我能够正确地console.log所有值,但是表达式img ng-src =“ {{$ scope.bus}}”“未被评估。我对angularJ很陌生,任何帮助都会很棒。下面是代码
$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.
})
};
答案 0 :(得分:0)
$ scope在这种情况下不起作用,因为它是一个孤立的。您可以尝试添加 locals 吗?谢谢。
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let notificationTitle = response.notification.request.content.title
let info = response.notification.request.content.userInfo
let data = info["moduledata"] as? String ?? ""
switch notificationTitle {
case "Notice Added":
let vc = NoticeDetailViewController()
vc.noticeID = data
let navVC = UINavigationController(rootViewController: vc)
window?.rootViewController = navVC
case "Practicework Added":
let vc = HomeworkDetailViewController()
vc.id = data
let navVc = UINavigationController(rootViewController: vc)
window?.rootViewController = navVc
default:
print("")
}
completionHandler()
}
或
按照第一种方法。
locals: {bus: $scope.bus}
答案 1 :(得分:0)
$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.
})
};