我通过 AngularJS 中的控制器将 html-partial 加载到 ng-view 指令中。 html 部分看起来像这样:
<div>
<ul data-role="listview" data-inset="true" data-theme="c">
<li><a href="#/detailsuser/a">A</a></li>
<li><a href="#/detailsuser/b">B</a></li>
<li><a href="#/detailsuser/c">C</a></li>
<li><a href="#/detailsuser/d">D</a></li>
</ul>
</div>
问题是列表视图没有渲染到 jquery-mobile-control 中。怎么了?
我让它工作了。这是我所做的:
我创建了一个附加在 ul 元素上的新指令。它会等到最后一个 li 元素渲染完毕,然后我调用 jqueryMobileTpl 指令上的触发器。
app.directive('jqueryMobileTpl', function () {
return {
link: function (scope, elm, attr) {
//elm.trigger('create');
}
};
});
app.directive('repeatDone', function () {
return function (scope, element, attrs) {
// When the last element is rendered
if (scope.$last) {
element.parent().parent().trigger('create');
}
}
});
and
<div jquery-mobile-tpl>
<ul data-role="listview" data-inset="true" data-theme="c" data-ng-repeat="customer in customers | orderBy:'lastName'" repeat-done="" ng-cloak>
<li><a href="#/customerdetails/{{customer.id}}" rel="external">{{customer.firstName + ' ' + customer.lastName}}</a></li>
</ul>
</div>
谢谢@CaioToOn 和@Omar!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)