javascript - using uibModal in angularJS v1.48 applcation
问题描述
I am trying to use uibModal (from angular-ui-bootstrap v0.12.1) in an angularJS application (v.148). I am aware of the current angular versions. When I am trying to use the modal using example code below, I am seeing the error:
TypeError: $uibModal.open is not a function
I have added the following to the application:
angular.module('someApp', ['ui.bootstrap']);
In the controller file, I am using the following:
angular.module('someAppController')
.controller('someController', ['$scope', '$http', $'location', '$modal', 'someService',
function($scope, $http, $locaton, $uibModal, someService) {
On an event:
$uibModal.open({
templateUrl: 'some.html',
windowClass: 'modal-danger'
});
I have tried replacing $uibModal to $modal (both in the module call and where I am trying to create the modal). However, I get the same error complaining about $uibModal.open or $modal.open is not a fucntion. Any thoughts on what I am doing wrong? I cannot find any issues with the versions or other dependencies causing issues.
解决方案
您的代码中有一些拼写错误,并且没有正确注入$uibModal
提供程序
改变
.controller('someController', ['$scope', '$http', $'location', '$modal', 'someService'
至
.controller('someController', ['$scope', '$http', '$location', '$uibModal', 'someService'
也改变
templateUrk: 'some.html',
至
templateUrl: 'some.html',
推荐阅读
- apache-spark - jdbc 在 Overwrite 模式下第一次运行后不插入数据
- typescript - 我有一个 ' "tsc.exe" exited with code 1 ' 错误,我该如何解决?
- powershell - Export-Csv -Append 实际上并没有附加第二组项目
- javascript - 相对于在另一个文本框中选择月份,如何仅在日期选择器中显示选定的月份日期?
- svn - 不要跟踪对配置文件的更改
- python - sqlite3.OperationalError:无法识别的令牌:“7nbtkq”
- flutter - Flutter ToggleButton 类 - Flutter 1.9.1
- django - 如何实现以下目标。?
- android - 重新安装应用后不会删除 Parse 当前用户
- android - Android onCreate extras