Javascript popover重画中的AngularJS自定义指令
我有一个按钮,可以触发带有自定义指令的popover。 问题是,单击按钮时,弹出框为空,只有当我强制角度循环时(更改输入字段中的数据等),自定义指令才会生效 一旦发生这种情况,popover将按预期使用自定义指令内容重新绘制 如何使自定义指令在打开popover时执行 一些代码: 按钮-Javascript popover重画中的AngularJS自定义指令,javascript,jquery,twitter-bootstrap,angularjs,Javascript,Jquery,Twitter Bootstrap,Angularjs,我有一个按钮,可以触发带有自定义指令的popover。 问题是,单击按钮时,弹出框为空,只有当我强制角度循环时(更改输入字段中的数据等),自定义指令才会生效 一旦发生这种情况,popover将按预期使用自定义指令内容重新绘制 如何使自定义指令在打开popover时执行 一些代码: 按钮- partials/test.html-(itemlist是自定义指令) itemlist指令- .directive('itemlist', function () { return {
partials/test.html-
(itemlist是自定义指令)
itemlist指令-
.directive('itemlist', function () {
return {
restrict: 'AE',
scope: { apicall: '=', editable: '=', viewtype: '=', selectable: '=' },
controller: function ($scope, $http, $resource, $timeout, fileReader, apiaddress, $dialog, errormsg) {
var resource = $resource(apiaddress + $scope.apicall, {}, { update: { method: 'PUT', params: { id: '@Id' } } });
$scope.apiresource = { list: resource.query() };
//TODO: See how to only display one.
toastr.info("Loading...");
},
templateUrl: function (tElement, tAttrs) { return tAttrs.template },
replace: true
};
})
还有一件事,itemlist
custom指令适用于应用程序的其他区域
谢谢大家! 由于资源正在异步检索数据,因此resource.query()不能保证同步返回数据。您可以尝试将线路更改为
$timeout(function () {
$scope.apiresource = {
list: resource.query()
};
});
谢谢我试过了,但不是这样。它永远不会走得那么远-似乎
partials/test.html
中的整个itemlist
指令在另一个角度循环被强制执行之前不会得到处理。。