作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
如何将可选参数传递给我的 angularJS 模态?这是我的代码:
Controller A(触发器):
$modal.open({
templateUrl: 'UploadPartial.html',
controller: 'photos.uploadCtrl',
resolve: {
preselectedAlbum: function preselectedAlbum() {
return angular.copy($scope.selectedAlbum);
}
}
});
Controller B(模态):
app.controller('photos.uploadCtrl', [
'$scope',
'$modalInstance',
'$injector',
function uploadCtrl($scope, $modalInstance, $injector) {
if ($injector.has('preselectedAlbum')) {
console.log('happy'); // I want this to work, but $injector doesn't find it
} else {
console.log('sad'); // Always gets here instead :(
}
}
]);
注意:当我将 preselectedAlbum
作为依赖项时,它会起作用,但是当我没有明确传递它时,我会收到错误。我希望它是可选的。
最佳答案
给模态 Controller 附加一个值
angular.module('app')
.controller('TestCtrl',TestCtrl)
.value('noteId', null); // optional param
关于javascript - AngularJS - 将可选参数传递给模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25046961/
我来自 Asp.Net 世界,试图理解 Angular State 的含义。 什么是 Angular 状态?它类似于Asp.Net中的ascx组件吗?是子页面吗?它类似于工作流程状态吗? 我听到很多人
我一直在寻找 3 态拨动开关,但运气不佳。 基本上我需要一个具有以下状态的开关: |开 |不适用 |关 | slider 默认从中间开始,一旦用户向左或向右滑动,就无法回到N/A(未回答)状态。 有人
我是一名优秀的程序员,十分优秀!