博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Angular js开发的各种坑(持续更新中。。。)
阅读量:7047 次
发布时间:2019-06-28

本文共 1444 字,大约阅读时间需要 4 分钟。

hot3.png

  1.  Angular UI的Modal 在按照官方文档写的时候会报如下错误

var ModalDemoCtrl = function ($scope, $modal, $log) {  $scope.items = ['item1', 'item2', 'item3'];  $scope.open = function (size) {    var modalInstance = $modal.open({      templateUrl: 'myModalContent.html',      controller: ModalInstanceCtrl,      size: size,      resolve: {        items: function () {          return $scope.items;        }      }    });    modalInstance.result.then(function (selectedItem) {      $scope.selected = selectedItem;    }, function () {      $log.info('Modal dismissed at: ' + new Date());    });  };};// Please note that $modalInstance represents a modal window (instance) dependency.// It is not the same as the $modal service used above.var ModalInstanceCtrl = function ($scope, $modalInstance, items) {  $scope.items = items;  $scope.selected = {    item: $scope.items[0]  };  $scope.ok = function () {    $modalInstance.close($scope.selected.item);  };  $scope.cancel = function () {    $modalInstance.dismiss('cancel');  };};

[$injector:unpr] Unknown provider: $modalInstanceProvider <- $modalInstance

google了一下,发现官方有人已经报过一个bug

官方解释是:

The problem was that you were specifying a controller in 2 places - when opening a modal and inside a template - this is not needed. Remove ng-controller from a template and things will work as expected:

原来,在写modal option的时候已经制定了Controller, 就没必要在template里面加ng-controller制定controller了

转载于:https://my.oschina.net/chenlei123/blog/297729

你可能感兴趣的文章
GDAL源码剖析(三)之Swig编译和帮助文档生成
查看>>
Android学习笔记:NDK入门一些总结
查看>>
Project Euler Problem 3: Largest prime factor
查看>>
颜色区分
查看>>
微信认证结果拆分为资质审核和名称审核
查看>>
Sass和Compass入门
查看>>
重装系统后删除Cygwin文件夹
查看>>
享元模式
查看>>
M4修改外部晶振8M和25M晶振的方法
查看>>
六、python小功能记录——递归删除bin和obj内文件
查看>>
EF架构~数据分批批量提交
查看>>
angular 数据内容有重复时不显示问题
查看>>
二叉树的路径和
查看>>
asp.net中JQuery AJAX的解决方案
查看>>
像素与rem转换
查看>>
urlencode遇到中文编码问题
查看>>
在一周之内,快速看完整部教材,列出你不懂的5-10个问题,发布在个人博客上。...
查看>>
Javascript:作用域 学习总结
查看>>
leetcode654
查看>>
利用WinRar命令行定时备份Sql2005数据库!
查看>>