我是AngularJS的新手并尝试使用ngDialog打开一个对话框。
这是我的控制者:
( function() {
var myController = function($scope, myService, ngDialog) {
$scope.title = "Getting data from service";
$scope.openReportDialog = function() {
alert("inside function");
ngDialog.open({ template: '<h1>Pranjal</h1>' });
};
myService.getPlan().success(function(r,s,x){
$scope.planData = r.plan;
});
myService.getPlan().success(function(r,s,x){
$scope.userData = r.plan;
});
};
angular.module("app").controller("myController", myController);
}());
这是我的观点文件:
<div class="container">
<button ng-click="openReportDialog()">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"> </span>
</button>
</div>
每次我收到此错误:
Uncaught SyntaxError: Unexpected token < dialog.js:1
Uncaught SyntaxError: Unexpected token < v_sample.html:1
Error: [$injector:unpr] http://errors.angularjs.org/1.4.5/$injector/unpr?p0=ngDialogProvider%20%3C-%20ngDialog%20%3C-%20myController
at Error (native)
at http://127.0.0.1:8020/OMS_Phase_3/lib/angular.min.js:6:416
at http://127.0.0.1:8020/OMS_Phase_3/lib/angular.min.js:40:307
at Object.d [as get] (http://127.0.0.1:8020/OMS_Phase_3/lib/angular.min.js:38:308)
at http://127.0.0.1:8020/OMS_Phase_3/lib/angular.min.js:40:381
at d (http://127.0.0.1:8020/OMS_Phase_3/lib/angular.min.js:38:308)
at e (http://127.0.0.1:8020/OMS_Phase_3/lib/angular.min.js:39:64)
at Object.g.instantiate (http://127.0.0.1:8020/OMS_Phase_3/lib/angular.min.js:39:213)
at b.$get (http://127.0.0.1:8020/OMS_Phase_3/lib/angular.min.js:80:257)
at $route.link (http://127.0.0.1:8020/OMS_Phase_3/lib/angular-route.js:977:26) <div ng-view="" class="ng-scope">
答案 0 :(得分:0)
您的错误消息表明应用程序无法获取所需的依赖项。正如您在评论中所说,您已经在模块定义中添加了“ngDialog”。您能否在加载应用程序时确认是否包含ngDialog.min.js
库(可能在index.html中)并且可以正确访问它?