无法读取property 'length'在旁边的未定义的
Cannot read property 'length' of undefined in aside
我使用ng-strap的modal、alert和aside。它们自己都工作得很好,但是当我试图把一个警报或模态放在一边时,它给了我这个错误:
Uncaught TypeError: Cannot read property 'length' of undefined.
这是一个plunkr: http://plnkr.co/edit/vLbDAarzpbT3qk0aNw12?p=preview
我使用了完全相同的代码(复制&
<button type="button" class="btn btn-default" data-animation="am-fade-and-scale" data-placement="center" bs-modal="myModal">Modal!</button>
<button type="button" class="btn btn-default" data-placement="top" data-container="body" data-duration="3" bs-alert="errorAlert">Alert!</button>
如何解决这个问题?
<div class="aside-body">
<button type="button" class="btn btn-default" data-animation="am-fade-and-scale" data-placement="center" ng-click="$isShown = false" bs-modal="myModal">Modal!</button>
<button type="button" class="btn btn-default" data-placement="top" data-container="body" data-duration="3" ng-click="$isShown = false" bs-alert="errorAlert">Alert!</button>
</div>
- ng-strap库在作用域中设置了一个变量$ isshow来指示模态当前是否正在打开。
- 当你点击"点击打开"时,它将该变量设置为true。当你点击旁边的"模态"按钮时,它会检查这个变量,看看它是打开的(但实际上是另一个模态),所以它会将模态切换为关闭。但是"modal"按钮的模态实际上还没有显示,导致错误
- 不确定什么是正确的方法来解决这个问题,因为我以前没有使用过这个库。让模态工作的一个"hack"是当你点击"modal"按钮时手动设置$ isdisplays变量为false,就像上面的代码:ng-click="$ isdisplays = false"
- Plunkr: http://plnkr.co/edit/qVy1Gol7RWGnsNUCMBWm?p=preview
相关文章:
- Microsoft JScript运行时错误:'Sys'未定义(在mvc3 c#剃刀中)
- jQuery 和 val() 未定义 在使用 Visual Studio 的 ASP.NET 上
- Window.opener 未定义在 IE8 中
- 面对此错误“ 未捕获的引用错误:幻灯片索引未定义 ”在光滑.js
- YUI 未定义 - 在 js 文件中创建所有内容
- “(回调方法)未定义”在 Firefox 插件上的 JSONP 访问中
- Heroku 生产:Gmaps 未定义 - 在本地工作
- appView 在运行时未定义在主干中
- 范围变量未定义在 angularjs 打字稿控制器类指令
- Nodejs - Req.body 未定义在 post 中,带有快速 4.9.0
- 反应 Redux 路由器 在 未定义 在操作中
- Jquery 未定义在外部 js 文件上
- 错误“包含”未定义在谷歌地图 JS API 中
- TypeError:[].文件未定义.在jquery文件中发布
- 在我为其他值使用替换函数之后,对变量进行未定义.在jquery中
- jsGettext Library "ReferenceError: str未定义"在firefox
- 套接字.用户名保持显示为未定义在我的客户端html
- AJAX响应,未定义(在控制台正常的JSON中)
- 删除确认返回未定义在chrome中
- 双重搜索vs未定义在JavaScript地图:TryGet通缉