Javascript AngularjS$注射器:unpr

Javascript AngularjS$注射器:unpr,javascript,angularjs,Javascript,Angularjs,我有以下控制器: /** Calculation controller **/ app.controller('calculationController', ['$scope','$modal','content', function($scope, $modal, content) { /** data recieved from get request **/ $scope.data = content.data; //promise /** function

我有以下控制器:

/** Calculation controller **/
app.controller('calculationController', ['$scope','$modal','content', function($scope, $modal, content) {

    /** data recieved from get request **/
    $scope.data = content.data; //promise

    /** function to edit data **/
    $scope.edit = function(item){

        var htmlContents = {
            title: 'Edit product',
            body: 'Please confirm that you want to edit the product'
        }

        var modalInstance = $modal.open({
            templateUrl : templateBase + 'views/modal/dialog.html',
            controller : 'modalInstanceController',
            resolve : {
                items : function() { return item; },
                html : function() { return htmlContents; }
            }
        });
    }

    /** function to delete data **/
    $scope.trash = function(item){

    }
}]);

app.controller('modalInstanceController', ['$scope', '$modalInstance','items','html', function($scope,$modalInstance,items,html) {
    $scope.title = html.title;
    $scope.body  = html.body;
}]);
我试图完成的是打开一个对话框,其中包含“dialog.html”中的内容,但是一旦我单击:

<img ng-src="images/icn_edit.png" ng-click="edit(item)" alt="Edit">

$injector:unpr出现在控制台日志中

dialog.html内容包括:

<div ng-controller="modalInstanceController">
<div class="modal-header">
    <h3>{{title}}</h3>
</div>
<div class="modal-body">
    {{body}}
</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>

{{title}}
{{body}}
好啊
取消

我知道我缺少注入一些东西,但是在看了几个小时的代码后,我找不到什么

从我观察到的情况来看,“$scope”、“$modalInstance”、“items”、“html”正在被注入modelInstanceController中

谢谢你的帮助


谢谢您

从dialog.html中删除

Ng-controller="modalInstanceController"
它应该是纯div,这样就可以了

dialog.html的html标记应如下所示:

<div>
<div class="modal-header">
    <h3>{{title}}</h3>
</div>
<div class="modal-body">
    {{body}}
</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>

{{title}}
{{body}}
好啊
取消

您的控制器中没有使用$http依赖项。删除该选项并检查错误是否仍然存在。如果不起作用,请共享您的模式对话框html模板谢谢您的回答,已测试,但问题仍然出现。-修订example@Gor81你能分享你的模态实例模板ie对话框吗。html@gor181“项”是否未定义?我在你的代码分配中没有看到它item@HarishR-项目是通过viewYour welcome提供的对象如果回答了,请向上投票并接受作为回答