首页 > 解决方案 > 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.

标签: javascriptangularjsangular-ui-bootstrap

解决方案


您的代码中有一些拼写错误,并且没有正确注入$uibModal提供程序

改变

.controller('someController', ['$scope', '$http', $'location', '$modal', 'someService'

.controller('someController', ['$scope', '$http', '$location', '$uibModal', 'someService'

也改变

templateUrk: 'some.html',

templateUrl: 'some.html',

推荐阅读