【发布时间】:2023-03-15 22:45:01
【问题描述】:
我正在尝试做一些事情,我猜这应该很容易,但我无法弄清楚。我想要做的就是点击一个按钮打开一个模式。我正在关注这个例子。 http://fdietz.github.io/recipes-with-angular-js/common-user-interface-patterns/displaying-a-modal-dialog.html
这是我的控制器:
var app = angular.module("MyApp", ["ui.bootstrap.modal"]);
app.controller('MyCtrl', function ($scope) {
$scope.open = function () {
$scope.showModal = true;
};
$scope.ok = function () {
$scope.showModal = false;
};
$scope.cancel = function () {
$scope.showModal = false;
};
});
这是我的观点:
<button class="btn" ng-click="open()">Open Modal</button>
<div modal="showModal" close="cancel()">
<div class="modal-header">
<h4>Modal Dialog</h4>
</div>
<div class="modal-body">
<p>Example paragraph with some text.</p>
</div>
<div class="modal-footer">
<button class="btn btn-success" ng-click="ok()">Okay</button>
<button class="btn" ng-click="cancel()">Cancel</button>
</div>
</div>
我收到错误消息 Error: [ng:areq] Argument 'MyCtrl' is not a function, got undefined.并且模式在加载时显示在页面上。提前致谢。
【问题讨论】:
-
哼这个问题没有出现在我的电脑上。你能告诉我们更多的代码吗?
-
@John' 你还想看什么其他代码?
-
嗯,也许你有很多代码。只是一个问题,您是否在代码中插入了指令“模态”?
-
@John' 不,我没有。它没有在示例中显示。我怎么做?抱歉,我对 AngularJS 真的很陌生。我很容易迷路:)
标签: angularjs twitter-bootstrap bootstrap-modal