$ uibModal没有打开,给出错误($uibModal not opening, giving errors)

系统教程 行业动态 更新时间:2024-06-14 16:58:30
$ uibModal没有打开,给出错误($uibModal not opening, giving errors)

所以我尝试了一切,每一个例子,我完全不知道什么是错的。 每当我尝试加载'$ uibModal'时,我都会收到错误并且所有的角度代码都会中断。 如果我没有正确加载它,那么我得到$ uibModal.open错误。 这是我的代码。 我现在的版本是0.14.3,我今天刚下载了这个文件。 如果它重要我的角度应用程序是在铁路和我使用凉亭导入一切。

我在js中加载的app.js文件。

var app = angular.module('planoxApp', ['ui.router', 'nya.bootstrap.select', // bootstrap select 'ngAnimate', 'ui.bootstrap', 'main-directives', 'templates', 'color.picker', 'xeditable', 'restangular', 'ngDragDrop', 'angularFileUpload', 'ngStorage' // 'mgcrea.ngStrap', // 'mgcrea.ngStrap.typeahead', // 'mgcrea.ngStrap.tooltip', // 'mgcrea.ngStrap.helpers.parseOptions', ])

ctrl加载区域,这会带来错误

[$ injector:unpr]未知提供者:$ uibModalProvider < - $ uibModal < - PhotoplanCtrl

app.controller('PhotoplanCtrl',['$http','$scope','$stateParams','$filter','$uibModal','$log', function($http,$scope, $stateParams,$filter,$uibModal,$log){

但如果我也改变它

app.controller('PhotoplanCtrl',['$http','$scope','$stateParams','$filter','$log', function($http,$scope, $stateParams,$filter,$uibModal,$log){

错误消失了,而我们得到了,错误:$ uibModal.open不是一个函数。 (在'$ uibModal.open'中,'$ uibModal.open'未定义)

这是模态代码

var modalInstance = $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'templates/photoplan/ModalPublish.html', controller: 'ModalPublishCtrl' });

如果有人知道什么是错的,那么任何帮助都非常感激。

So I have tried everything, every example, I have absolutely no idea whats wrong. Whenever I try to load in '$uibModal' I get errors and all of my angular code breaks. If I dont load it in properly then i get $uibModal.open errors. Here is my code. I am at the current version of 0.14.3, I just downloaded the file today. If it matters my angular app is in rails and im using bower to import everything.

The app.js file where I loaded in my js.

var app = angular.module('planoxApp', ['ui.router', 'nya.bootstrap.select', // bootstrap select 'ngAnimate', 'ui.bootstrap', 'main-directives', 'templates', 'color.picker', 'xeditable', 'restangular', 'ngDragDrop', 'angularFileUpload', 'ngStorage' // 'mgcrea.ngStrap', // 'mgcrea.ngStrap.typeahead', // 'mgcrea.ngStrap.tooltip', // 'mgcrea.ngStrap.helpers.parseOptions', ])

The ctrl loading area, this brings up the error

[$injector:unpr] Unknown provider: $uibModalProvider <- $uibModal <- PhotoplanCtrl

app.controller('PhotoplanCtrl',['$http','$scope','$stateParams','$filter','$uibModal','$log', function($http,$scope, $stateParams,$filter,$uibModal,$log){

But if i change it too

app.controller('PhotoplanCtrl',['$http','$scope','$stateParams','$filter','$log', function($http,$scope, $stateParams,$filter,$uibModal,$log){

The error goes away, and instead we get, Error: $uibModal.open is not a function. (In '$uibModal.open', '$uibModal.open' is undefined)

Here is the modal code

var modalInstance = $uibModal.open({ animation: $scope.animationsEnabled, templateUrl: 'templates/photoplan/ModalPublish.html', controller: 'ModalPublishCtrl' });

If anyone knows whats wrong, any help is really appreciated.

最满意答案

好吧首先,在我的模态html中你不能有ng-controller。 显然bootstrap处理它,所以我的新HTML看起来像。

<div class="modal-header" > <h3 class="modal-title">Account Settings</h3> </div> <div class="modal-body"> <ul> <li> <p>An option to chage password and account username </p> <p>An option to change time settings </p> <p> </p> </li> </ul> </div> <div class="modal-footer"> <button class="btn btn-warning" type="button" ng-click="cancel()">Close</button> </div>

也是由于某种原因,它无法在我的导轨管道或角度加载正确,这是非常奇怪的。 我可能会在github上报告一个问题,但是我只是将CDN添加到我的index.html文件中,它开始正常工作。

Okay so first things first, in my modal html you cant have ng-controller. Apparently bootstrap handles it, so my new html looks like.

<div class="modal-header" > <h3 class="modal-title">Account Settings</h3> </div> <div class="modal-body"> <ul> <li> <p>An option to chage password and account username </p> <p>An option to change time settings </p> <p> </p> </li> </ul> </div> <div class="modal-footer"> <button class="btn btn-warning" type="button" ng-click="cancel()">Close</button> </div>

Also for some reason it is not loading properly either in my rails pipeline or in angular, which is very strange. I might report an issue on github for that one, but otherwise I just added the CDN to my index.html file and it started to work properly.

更多推荐

本文发布于:2023-04-15 03:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/dda41a9aaccad10f720d9ed0ca91b985.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   uibModal   opening   errors   giving

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!