Angularjs 尝试弹出模式窗口-使用角度和引导
首先,我正处于Angular的初级阶段,所以我很自然地希望我的问题很简单,但无法确定它们是什么和在哪里 我有一个通知列表,显示在一对ul标签中。通知正文通常会被截断。当用户单击通知时,将弹出一个模式窗口,显示通知的全文 两个问题:Angularjs 尝试弹出模式窗口-使用角度和引导,angularjs,controller,modal-dialog,Angularjs,Controller,Modal Dialog,首先,我正处于Angular的初级阶段,所以我很自然地希望我的问题很简单,但无法确定它们是什么和在哪里 我有一个通知列表,显示在一对ul标签中。通知正文通常会被截断。当用户单击通知时,将弹出一个模式窗口,显示通知的全文 两个问题: 模态窗口确实弹出了,但是通知的主体根本没有显示,相反,我看到了 {{$scope.Display_Notification.text}} 我收到一条错误消息,说明参数“ShowNotificationDialog”不是函数,未定义 以下是对话的HTML: <
{{$scope.Display_Notification.text}}
<script type="text/ng-template" id="show-notification-details.html">
<div class="modal-header">
<h3 class="modal-title">
Notification Details...
</h3>
</div>
<div class="modal-body" ng-controller="ShowNotificationDialog">
<div id="Display_Notification_Body">
This should be the "text" field: >>{{$scope.Display_Notification.text}}<<
</div>
</div>
<div class="modal-footer">
<div class="btn-group">
<button class="btn btn-primary" style="width:140px" ng-click="Dismiss_Notification()">Dismiss</button>
</div>
</div>
</script>
模态窗口的控制器如下所示:
:
:
var ShowNotificationDialog = (function (p_Notif) {
function ShowNotificationDialog($scope, $modalInstance , p_Notif ) {
console.log("*** Log 1 in ShowNotificationDialog ***") ;
}
ShowNotificationDialog.$inject = ['$scope', '$modalInstance' ];
return ShowNotificationDialog;
})();
:
:
控制台(Chrome)的内容包括:
:
:
=== Log 1 in OpenNotificationDialog ===
=== Log 2 in OpenNotificationDialog ===
=== Log 1 in ShowNotificationDialog ===
angular.js:11655 Error: [ng:areq] Argument 'ShowNotificationDialog' is not a function, got undefined
http://errors.angularjs.org/1.3.15/ng/areq?p0=ShowNotificationDialog&p1=not%20aNaNunction%2C%20got%20undefined
at REGEX_STRING_REGEXP (chrome-extension://hcdgjohfmldbigeocpolkcekdojldfcj/vendor/angularjs/angular.js:63:12)
:
:
我猜您使用的是angular ui引导,您应该遵循他们的文档,查看模态组件的示例:
- 在视图/模板中时,不需要在范围变量上指定$scope。
将
替换为{{$scope.Display_Notification.text}}
{{Display_Notification.text}
- 语法很奇怪,你的控制器声明正确吗?(查看官方文件:)
- 在视图/模板中时,不需要在范围变量上指定$scope。
将
替换为{{$scope.Display_Notification.text}}
{{Display_Notification.text}
- 语法很奇怪,你的控制器声明正确吗?(查看官方文件:)
:
:
=== Log 1 in OpenNotificationDialog ===
=== Log 2 in OpenNotificationDialog ===
=== Log 1 in ShowNotificationDialog ===
angular.js:11655 Error: [ng:areq] Argument 'ShowNotificationDialog' is not a function, got undefined
http://errors.angularjs.org/1.3.15/ng/areq?p0=ShowNotificationDialog&p1=not%20aNaNunction%2C%20got%20undefined
at REGEX_STRING_REGEXP (chrome-extension://hcdgjohfmldbigeocpolkcekdojldfcj/vendor/angularjs/angular.js:63:12)
:
: