我试图在视图加载时显示模态。类型错误:无法读取未定义的属性'childNodes'
代码:
//View
<div id="showCom" ng-controller="showmodalCtrl" ng-init="init()">
<div class="modal fade" id="companyModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Please Select Company</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label class="control-label">Recipient:</label>
<input type="text" class="form-control">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
//Controller
.controller('showmodalCtrl', ['$scope', function($scope){
$scope.init = function(){
$('#companyModal').modal("show");
}
}])
一切正常,并显示模式,但我得到的控制台上的错误:
Type error : Cannot read property 'childNodes' of undefined
我不知道为什么这个正在发生。 此外,如果我从模态中删除“表单”,我不会收到任何错误。所以我想这个问题是与表格有关,但我无法解决它。
在此先感谢。
你包含'jQuery'吗?您正在使用'$('#companyModal')'选择器来选择带有'jQuery'的元素。 –
@MohitPandey ..是的,我包括jquery – Zee
它很难追查这个代码的错误。尝试创建它的http://jsfiddle.net/。此外,内部控制器'''是angular而不是jQuery的引用。尝试使用'jQuery('#companyModal')'。 –