我有功能从我的Scope中的数组获取modal templateUrl的url。 然后我在我的李上使用这个功能为我的模态添加网址。 但是当我点击li时,showReleventMdl()函数将执行并在console.log()中显示url字符串,但我的模态消失了,我发现这个错误:
未捕获的TypeError:无法读取未定义的属性“焦点”
这里是我的代码:
app.controller('filterCtrl', function($scope,$modal, $rootScope ,loginService ) {
var filterTemps = [
"partial/uiComponent/mdlFilters/mdl.estateType.filter.html",
'partial/uiComponent/mdlFilters/mdl.dealKind.filter.html',
'partial/uiComponent/mdlFilters/mdl.buyPrice.filter.html',
'partial/uiComponent/mdlFilters/mdl.trustPrice.filter.html',
'partial/uiComponent/mdlFilters/mdl.rentPrice.filter.html',
'partial/uiComponent/mdlFilters/mdl.forigenPrice.filter.html',
'partial/uiComponent/mdlFilters/mdl.totalRoom.filter.html',
'partial/uiComponent/mdlFilters/mdl.substructure.filter.html'
];
var filtersModal = $modal({
backdrop:true,
placement:'top',
controller : 'filterCtrl',
templateUrl:'',
show: false
});
$scope.showReleventMdl = function(num) {
filtersModal.templateUrl = filterTemps[num];
console.log(filtersModal.templateUrl);
filtersModal.$promise.then(filtersModal.show);
};
});
<div class="collapse navbar-collapse" ng-class="!navCollapsed && 'in'" ng-click="navCollapsed = true">
<!-- your normal collapsable content here -->
<ul class="nav navbar-nav">
<li><a href="" ng-click="showReleventMdl(0)" ng-bind="string.pages.form.estateType"></a><span>: a<span></li>
<li><a href="" ng-click="showReleventMdl(1)" ng-bind="string.pages.form.dealKind"><span>: b </span></a></li>
<li><a href="" ng-click="showReleventMdl(2)" ng-bind="string.pages.form.buyPrice"><span>: c </span></a></li>
<li><a href="" ng-click="showReleventMdl(3)" ng-bind="string.pages.form.trustPrice"><span>: d </span></a></li>
<li><a href="" ng-click="showReleventMdl(4)" ng-bind="string.pages.form.rentPrice"><span>: g </span></a></li>
<li><a href="" ng-click="showReleventMdl(5)" ng-bind="string.pages.form.forigenPrice"><span>: e </span></a></li>
<li><a href="" ng-click="showReleventMdl(6)" ng-bind="string.pages.form.totalRoom"><span>: f </span></a></li>
<li><a href="" ng-click="showReleventMdl(7)" ng-bind="string.pages.form.substructure"><span>: g </span></a></li>
</ul>
</div>
答案 0 :(得分:0)
我只是把Modal放在我的showReleventMdl()函数中,每一件事看起来都很好。
但我仍然不知道为什么?