我想我错过了什么,但无法弄清楚是什么.
基本上我正试图将一个对象传递给下面的模态,但是我没有得到传递的对象,而是获得null ...所以我认为是范围的问题,但我是Angular中的新手,需要一些帮助.
调节器
app.controller("musicViewModel", function ($scope, $http, $location, $uibModal, $log) {
$scope.selected = null;
$scope.open = function (item) {
$scope.selected = item;
$log.info('Open' + $scope.selected); // get right passes object
var modalInstance = $uibModal.open({
templateUrl: 'myModalContent.html',
controller: 'musicViewModel',
size: 'lg',
resolve: {
items: function () {
return $scope.selected;
}
}
});
};
$scope.toggleAnimation = function () {
$scope.animationsEnabled = !$scope.animationsEnabled;
};
});
Run Code Online (Sandbox Code Playgroud)
视图
<div class="row" ng-controller="musicViewModel">
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h3 class="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body">
<ul> …Run Code Online (Sandbox Code Playgroud) twitter-bootstrap angularjs angular-ui angularjs-controller bootstrap-modal