gpt4 book ai didi

templates - Angular 模态模板不显示

转载 作者:行者123 更新时间:2023-12-02 01:57:26 24 4
gpt4 key购买 nike

我对 Angular 有点陌生。当检测到无效的用户 Angular 色时,我试图显示 Bootstap 3 模式对话框。我无法显示模态模板。这种行为似乎有效,即我可以忽略褪色的叠加层。我只是看不到实际的模态模板。

Bootstrap 3AngularJS 1.0.7AngularJS 用户界面 Bootstrap 0.6.0

Controller

gsApp.controller('MainController', ['$rootScope', '$scope', '$q', '$window', '$location',     '$modal', 'ApplicationCache', 'UserService',
function MainController($rootScope, $scope, $q, $window, $location, $modal, ApplicationCache, UserService) {

$scope.userRole = "BadRole";

$scope.showBadRoleModel = function () {
var showBadRoleModelInstance = $modal.open({
templateUrl: "badRoleModal.html",
backdrop: true,
windowClass: 'modal',
controller: badRoleModalInstance,
resolve: {
items: function () {
return $scope.userRole;
}
}
});
}

var badRoleModalInstance = function($scope, $modalInstance, items){
$scope.ok = function () {
$modalInstance.close();
};

$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}
}]);

HTML

<div class="row" ng-controller="MainController">

<script type="text/ng-template" id="badRoleModal.html">
<div class="modal-header">
<h3>I'm a modal!</h3>
</div>
<div class="modal-body">
<h2>body</h2>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
</script>

<button class="btn" ng-click="showBadRoleModel()">Show bad role modal</button>
</div>

最佳答案

AngularJs UI Bootstrap 还不适用于 Bootstrap 3。

在此处查看更多详细信息:https://github.com/angular-ui/bootstrap/issues/331

关于templates - Angular 模态模板不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19166176/

24 4 0