2014-07-19 84 views
0

我有以下控制器:

/** 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> 

我知道,我的思念中注入什么东西的看着我无法找到什么代码小时后然而...

从我可以看到 '$范围', '$ modalInstance', '项', 'HTML' 正在在modelInstanceController注入..

任何帮助表示赞赏。

谢谢

+0

您没有在控制器中使用$ http依赖项。删除它并检查你的错误是否持续。如果它不工作共享你的模态对话框html模板 – V31

+0

感谢您的答案,测试但问题仍然出现。 - 修改示例 – gor181

+0

@Gor81你可以分享你的模态实例模板,即dialog.html – V31

回答

1

从你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> 
+0

谢谢,做了伎俩......微不足道但让我头痛。 – gor181

+0

欢迎您如果回答请upvote并接受为答复 – V31

+0

接受:)我需要15rep积分upvote。干杯。 – gor181

相关问题